C#的StreamReader读文件

using System;
using System.IO;
using System.Collections;

namespace TextFileReader_csharp
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		static void Main(string[] args)
		{
			StreamReader objReader = new StreamReader("c:\\test.txt");
			string sLine="";
			ArrayList arrText = new ArrayList();

			while (sLine != null)
			{
				sLine = objReader.ReadLine();
				if (sLine != null)
					arrText.Add(sLine);
			}
                        objReader.Close();

			foreach (string sOutput in arrText)
				Console.WriteLine(sOutput);
			Console.ReadLine();
		}
	}
}

你可能感兴趣的:(C#的StreamReader读文件)