Reading a text file with StreamReader
1 2 private void ImportCountries() 3 { 4 string delimiter = ","; 5 string fileName = @"c:\countrylist3.csv"; 6 7 StreamReader sr = new StreamReader(fileName); 8 9 try 10 { 11 while (sr.Peek() >= 0) 12 { 13 string r = sr.ReadLine(); 14 string[] items = r.Split(delimiter.ToCharArray()); 15 } 16 } 17 finally 18 { 19 sr.Close(); 20 } 21 } 22