c#将数据写入记事本需要控件吗?

2024-12-01 14:51:11
推荐回答(2个)
回答1:

不用
using System.IO;
try
{
FileStream stream = new FileStream("test.txt", FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(stream);
string text="hello world";
sw.WriteLine(text);
sw.Close();
stream.Close();
}
catch (IOException e)
{
MessageBox.Show(e.Message);
}

回答2:

直接写进txt文件就可以了