求.net中将文本导出为txt文件的代码

谁给我一份能用的代码啊
2025-05-08 04:07:43
推荐回答(1个)
回答(1):

Web项目写入一个temp.txt文件:

if (!this.IsPostBack)
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath(".") + "\\" + "temp.txt");
sw.WriteLine("这里是写入的文本。");
sw.WriteLine("再写一行");
sw.Flush();
sw.Close();

}

该文章转自:站点基地 ".net中将文本导出为txt文件的方法"一文