【发布时间】:2019-08-15 00:32:45
【问题描述】:
从 i is nub 开始 我正在编写一个应用程序以使用文本文件中的链接列表从 curseforge 下载 mods,当我尝试使用表单中的文本框写入该文件时
private void textBox1_TextChanged(object sender, EventArgs e)
{
//this code segment write data to file.
FileStream fs1 = new FileStream("Addons.AMU", FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter writer = new StreamWriter(fs1);
writer.Write(FileList1);
writer.Flush();
writer.Close();
}
但是,当我阅读它打印的文件时 System.Windows.Forms.TextBox,文本:(这里是乱码)...
为什么它会打印几个字符然后...?
如果我写
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
hello world!
我希望输出与输出完全相同,但输出为
System.Windows.Forms.TextBox, Text: hello world!
hello world!
hello world!....
【问题讨论】:
-
你打电话给
writer.Write(FileList1);。那是试图将TextBox对象本身写给作者。我怀疑你的意思是writer.Write(FileList1.Text); -
感谢您的帮助,我真的很感激
标签: c# streamwriter