private void bntAddPlayer_Click(object sender, RoutedEventArgs e) { string item = txtPlayerName.Text; string container = ""; int counter = 0; string line; StreamReader file = new StreamReader(@"c:\JDR(Lisa)\PlayerCreation.txt"); while ((line = file.ReadLine()) != null) { if (counter == 0) { container = item + "" + container; } else { container = container + " " + line; } counter++; } file.Close(); Service.TXTFile tf = new Service.TXTFile(); tf.write(container, "Player"); tf.clearPlayerCreation(); MainWindow mn = new MainWindow(); mn.Show(); this.Close(); }
private void btnAddEn_Click(object sender, RoutedEventArgs e) { try { if (lboxEnnemyListAdd.SelectedItem != null) { string ennemy = "" + lboxEnnemyListAdd.SelectedItem; string line; string container = ""; StreamReader file = new StreamReader(@"c:\JDR(Lisa)\ListEnnemy.txt"); while ((line = file.ReadLine()) != null) { string[] words = line.Split(' '); // Get Name if (ennemy == words[0]) { Service.Service serv = new Service.Service(); string id = serv.RandomString(6); container = id + "/" + words[0] + " " + words[1] + " " + words[2] + " " + words[3] + " " + words[4] + " " + words[5] + " " + words[6]; } } file.Close(); Service.TXTFile tf1 = new Service.TXTFile(); tf1.write(container, "GameEnnemy"); WAddEnnemy sten = new WAddEnnemy(); sten.Show(); this.Close(); } else { MessageBox.Show("Aucune ligne n'est sélectionnée."); } } catch (Exception error) { MessageBox.Show(error.Message); }; }