Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Casper Skovgaard

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

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  
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS