private void button1_Click(object sender, EventArgs e) { string sLine = ""; using (StreamReader sr = new StreamReader(@"c:\Text.txt")) { while (!sr.EndOfStream) { sLine = sr.ReadLine(); listBox1.Items.Add(sLine); } MessageBox.Show("Completed..!"); } }
ListBox
System.Collections.Generic.HashSet<>
ListView
listBox1.Items.AddRange( File.ReadLines( @"C:\Text.txt" ).Distinct().Where( s => ! listBox1.Items.Contains( s )).ToArray() )
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)