如何使用c#复制文本框中的文本文件?

如何使用c#复制文本框中的文本文件?,c#,textbox,text-files,C#,Textbox,Text Files,我喜欢将整个文本文件复制到多行文本框中,如何执行这些操作?使用System.IO命名空间中的类(例如文件) 使用ReadAllLines方法将文件作为字符串数组读取,并将其放入文本框: TheTextBox.Lines = File.ReadAllLines(fileName); textBox1.Text = System.IO.File.ReadAllText(path); string value1 = System.IO.File.ReadAllText("C:\\file.txt

我喜欢将整个文本文件复制到多行文本框中,如何执行这些操作?

使用
System.IO
命名空间中的类(例如
文件


使用
ReadAllLines
方法将文件作为字符串数组读取,并将其放入文本框:

TheTextBox.Lines = File.ReadAllLines(fileName);
 textBox1.Text = System.IO.File.ReadAllText(path);
string value1 = System.IO.File.ReadAllText("C:\\file.txt");
System.IO.File.WriteAllText("C:\\file.txt","Hello!");
using (StreamReader sr = new StreamReader(path)) 
{            
   textbox1.Text = sr.ReadToEnd());
}
TheTextBox.Lines = File.ReadAllLines(fileName);
       using (StreamReader reader = File.OpenText(@"C:\your_file.txt"))

        myTextBox.Text = reader.ReadLine();