如何引用外部.txt文本文档在窗体中的文本框中显示.txt中的内容?
应该怎么写这样的程序?

解决方案 »

  1.   

    System.Diagnostics.Process.Start("notepad");
      

  2.   

    流读取
     StreamReader objReader = new StreamReader(HttpContext.Current.Server.MapPath("用户协议.txt"), System.Text.Encoding.Default);
            string str = objReader.ReadToEnd();
            objReader.Close();str就是你要的内容
      

  3.   

    理解错了!
    StreamReader hc = new StreamReader(@"C:\database.sql");
                string ss = hc.ReadToEnd();
                this.richTextBox1.Text = ss.ToString();
      

  4.   

    TextBox1.Text=File.ReadAllText("d:\\test.txt");
      

  5.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    namespace ConsoleApplication14
    {
        class Program
        {
            static void Main(string[] args)
            {
                FileStream fs = new FileStream("C:\\list.txt", FileMode.Open, FileAccess.Read);
                StreamReader sr = new StreamReader(fs);
                string str = sr.ReadToEnd();
                Console.WriteLine(str);
            }
        }
    }
      

  6.   


    private string Read( string file )
    { StreamReader reader = new StreamReader( file );
     string data = reader.ReadToEnd ();
     reader.Close(); return data;
    } string data = Read( @"c:\temp.txt" );
     textBox1.Text = data;
      

  7.   

    如果.txt中是分多个内容(n条信息),在文本框中显示时,并不是同时显示,而是一条条进行显示,如何编写~
      

  8.   

    System.IO.StreamReader st;
    st = new System.IO.StreamReader(filepath, System.Text.Encoding.ASCII);
    TextBox1.Text = st.ReadLine();
    st.Close();