c# - 为什么我的 C# Writer.Write(Filelist1) 只写 1kb
问题描述
当我尝试使用表单中的文本框写入该文件时,我正在编写一个应用程序以使用文本文件中的链接列表从 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, Text: (random bs gibberish here)...
为什么它会打印几个字符然后......?
如果我写
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);
至
writer.Write(FileList1.Text);
推荐阅读
- php - 我想在表单中显示外键的值
- linux - 如何在不使用 YUM 实用程序的情况下在 RHEL7 中安装 postgresql 9.3 dB
- tfs - vnext 构建中可用于临时文件的正确(由管道管理)目录是什么?
- php - Substr 没有返回正确的值
- android - 有没有办法在 Gradle 中为 Android 检测测试设置 jvmArgs?
- c# - 制作通话记录器应用程序的正确方法是什么,该应用程序记录呼叫者和接收者的声音
- ssas - SSAS 表格 1400 项目停留在“验证凭据”上
- python - 将 Tensorflow 数据集 API 与 Keras 一起使用时的问题
- laravel - Laravel AppServiceProvider Auth::guard('admin')->check() 不工作
- laravel - 通过 BelongsToMany 关系的 HasMany 关系