下面是關于StreadReader的使用例子。
完整代碼如下:
引入命名空間:
using System.IO;
完整代碼:
namespace StreamReaderApp
{
class Program
{
static void Main(string[] args)
{
string s = "";
using (StreamReader sr = new StreamReader("c:\\file1.txt"))
{
s = sr.ReadToEnd();
}
Console.WriteLine(s);
Console.ReadLine();
}
}
}
參考:http://www.wxzzz.com/?id=32
轉載于:https://www.cnblogs.com/andrew-blog/archive/2011/12/02/CSharp_StreamReader.html