private void button3_Click(object sender, EventArgs e) { OpenFileDialog theDialog = new OpenFileDialog(); theDialog.Title = "Файлро интихоб кунед"; theDialog.Filter = "TXT files|*.txt"; theDialog.InitialDirectory = @"C:\"; if (theDialog.ShowDialog() == DialogResult.OK) { try { var path = theDialog.FileName; var lines = File.ReadAllLines(path); foreach (var item in lines) { if (!NewStopWords.Any(s => s == item)) { NewStopWords.Add(item); if (!listBox1.Items.Contains(item)) { listBox1.Items.Add(item); } } } } catch (Exception ex) { MessageBox.Show("Хатогӣ ҳангоми хондани файл: " + ex.Message); } } }
private void button5_Click(object sender, EventArgs e) { var newStopWord = ShowDialog("СТОП-КАЛИМА", "Ҳамроҳ кардани калимаи нав").Trim(); if (newStopWord != "" && newStopWord != null) { if (!NewStopWords.Any(s => s == newStopWord)) { NewStopWords.Add(newStopWord); if (!listBox1.Items.Contains(newStopWord)) { listBox1.Items.Add(newStopWord); } } } }