Home
Manage Your Code
Snippet: TXT File Reader (C#)
Title: TXT File Reader Language: C#
Description: Fragment to read a txt file Views: 1605
Author: Paulo Almeida Date Added: 11/23/2007
Copy Code  
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace LabelPrinter
7{
8    class Program
9    {
10        static void Main(string[] args)
11        {
12            string file = @"C:\Documents and Settings\kaa8823\My Documents\Visual Studio 2005\Projects\Classes\Solution\LabelPrinter\LabelPrinter\Resources\Labeltest1.lbl";
13            string strLine = "";
14            StreamReader sr = new StreamReader(file);
15            while (!sr.EndOfStream)
16            {
17                  strLine = sr.ReadLine().ToString();
18                Console.WriteLine(strLine);
19            }
20            sr.Close();
21            Console.ReadLine();
22        }
23    }
24}
Notes
http://msdn.microsoft.com/en-us/library/db5x7c0d(VS.80).aspx