string name1 = txt4.Text;
string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);//结果保存到桌面
FileStream fs = System.IO.File.Create(path + @"\" + name1 + ".txt");
StreamWriter sw=new StreamWriter(fs);//创建输入流
sw.Write(""); //写入文本信息
fs.Close(); //关闭文件流
MessageBox.Show("桌面文本文件创建成功!");
Process.Start(path + @"\" + name1 + ".txt");//打开该文件
c#创建文本文件txt
最新推荐文章于 2024-06-24 11:23:30 发布