Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace INP_Login
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button_save_Click(object sender, EventArgs e)
- {
- string username = input_username.Text;
- string password = input_password.Text;
- string auto = input_autologin.Checked ? "1" : "0";
- Properties.Settings.Default.Save();
- try
- {
- string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- string specificFolder = Path.Combine(folder, "INPLogin");
- string saveFile = Path.Combine(specificFolder, "Save.cfg");
- Console.WriteLine("Config saved!");
- StreamWriter sw = new StreamWriter(saveFile);
- sw.WriteLine(username);
- sw.WriteLine(password);
- sw.WriteLine(auto);
- sw.Close();
- }
- catch(Exception e1)
- {
- Console.WriteLine("Error: " + e1.Message);
- }
- }
- private void Form1_Shown(object sender, EventArgs e)
- {
- string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- string specificFolder = Path.Combine(folder, "INPLogin");
- if (!Directory.Exists(specificFolder))
- Directory.CreateDirectory(specificFolder);
- Console.WriteLine("Window shown! Loading config file");
- //input_username.Text = (string)Properties.Settings.Default["username"];
- string saveFile = Path.Combine(specificFolder, "Save.cfg");
- if (File.Exists(saveFile))
- {
- StreamReader sr = new StreamReader(saveFile);
- input_username.Text = sr.ReadLine();
- input_password.Text = sr.ReadLine();
- input_autologin.Checked = (sr.ReadLine() == "1") ? true : false;
- sr.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement