private void AddButton_Click(object sender, EventArgs e) { if (column != 6 && row != 9) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Exe Files (.exe)|*.exe"; openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { StreamReader sr = new StreamReader(@"D:\Projects\App\GameLauncherV2\GameLauncherV2\Data.txt"); string contents = sr.ReadToEnd(); sr.Close(); if (!contents.Contains(openFileDialog.FileName)) { NewFile file = new NewFile(openFileDialog.FileName, TableGrid); using (StreamWriter writer = new StreamWriter(@"D:\Projects\App\GameLauncherV2\GameLauncherV2\Data.txt", append: true)) { writer.WriteLine(openFileDialog.FileName); writer.Close(); } } else { MessageBox.Show("Error this shortcut is already there"); } } } else { MessageBox.Show("For add remove something"); } }
public LoadFile(TableLayoutPanel TableGrid) { string[] lines = File.ReadAllLines(@"D:\Projects\App\GameLauncherV2\GameLauncherV2\Data.txt"); foreach (var path in lines) { NewFile file = new NewFile(path, TableGrid); } }
private void Button_Click(object sender, EventArgs e) { if (!Form1.remove) { System.Diagnostics.Process.Start(path); } else { Form1.labelList.Remove(panelLabel); string[] lines = File.ReadAllLines(@"D:\Projects\App\GameLauncherV2\GameLauncherV2\Data.txt"); var list = new List <string>(); foreach (var line in lines) { list.Add(line); if (list.Contains(path)) { list.Remove(path); } } File.WriteAllText(@"D:\Projects\App\GameLauncherV2\GameLauncherV2\Data.txt", string.Empty); using (StreamWriter sw = new StreamWriter(@"D:\Projects\App\GameLauncherV2\GameLauncherV2\Data.txt", append: true)) { foreach (var item in list) { sw.WriteLine(item); } sw.Close(); } } TableLayoutPanel.Controls.Clear(); string[] linesN = File.ReadAllLines(@"D:\Projects\App\GameLauncherV2\GameLauncherV2\Data.txt"); Form1.column = 0; Form1.row = 0; Form1.counter = 0; foreach (var item in linesN) { NewFile file = new NewFile(item, this.TableLayoutPanel); } }