【C#学习笔记】读文件

using System;
using System.IO;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            FileStream file = new FileStream("log.txt", FileMode.OpenOrCreate);
            StreamReader sr = new StreamReader(file);
            string a = sr.ReadToEnd();
            Console.Write(a);   
            sr.Close();

            Console.Read();
        }      
    }
}

 

posted @ 2017-08-27 15:07  Dsp Tian  阅读(396)  评论(0编辑  收藏  举报