怎么能读取txt文件的所有内容

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;namespace ConsoleApplication14
    {
        class Program
        {
            static void Main(string[] args)
            {
                StreamReader reader = new StreamReader(@"c:\a.txt");
                string content = reader.ReadToEnd();//这句是关键,从流的开始读到流的结束
                Console.WriteLine(content);
                Console.ReadLine();
            }
        }
    }
      

  2.   


            using (StreamReader sr = new StreamReader("my.txt"))
            {
                string content = sr.ReadToEnd();
            }
      

  3.   

                StreamReader hc = new StreamReader(@"C:\database.txt");
                string ss = hc.ReadToEnd();
                this.richTextBox1.Text = ss.ToString();
      

  4.   

     StreamReader reader = new StreamReader("路径"); 
     string content = reader.ReadToEnd();