1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
public partial class Form1 : Form
{
List<string> Accounts = new List<string>();
public Form1()
{
InitializeComponent();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
LoadAccounts();
}
private void BoutonLogin_Click(object sender, EventArgs e)
{
}
private void buttonCreate_Click(object sender, EventArgs e)
{
string newAccount = textBoxLogin.Text + "," + textBoxMotDePasse.Text;
Accounts.Add(newAccount);
saveAccounts();
MessageBox.Show("Compte Créé");
}
private void LoadAccounts()
{
using (StreamReader SR = new StreamReader(@"C:\Accounts.txt"))
{
while (SR.EndOfStream == false)
{
Accounts.Add(SR.ReadLine());
}
}
}
private void saveAccounts()
{
using (StreamWriter SW = new StreamWriter(@"C:\Accounts.txt"))
{
for (int i = 0; i < Accounts.Count; i++)
{
SW.WriteLine(Accounts[i]);
}
}
} |
Partager