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

Reading a text file with StreamReader (See related posts)


  private void ImportCountries()
  {
    string delimiter = ",";
    string fileName = @"c:\countrylist3.csv";

    StreamReader sr = new StreamReader(fileName);

    try
    {
      while (sr.Peek() >= 0)
      {
        string r = sr.ReadLine();
        string[] items = r.Split(delimiter.ToCharArray());
      }
    }
    finally
    {
      sr.Close();
    }
  }


You need to create an account or log in to post comments to this site.


Click here to browse all 4852 code snippets

Related Posts