文件流输出文件并下载,该怎么处理
文件流输出文件并下载
现在想要把一个字符串输出为txt文件并直接下载,要怎么做
------解决方案--------------------
代码来自:
http://stackoverflow.com/questions/14755339/download-text-as-file-in-asp-net
------解决方案--------------------
http://blog.****.net/wangnaisheng/article/details/32330857
现在想要把一个字符串输出为txt文件并直接下载,要怎么做
------解决方案--------------------
protected void Button18_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
string output = "Output";
sb.Append(output);
sb.Append("\r\n");
string text = sb.ToString();
Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Content-Length", text.Length.ToString());
Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "attachment;filename=\"output.txt\"");
Response.Write(text);
Response.End();
}
代码来自:
http://stackoverflow.com/questions/14755339/download-text-as-file-in-asp-net
------解决方案--------------------
http://blog.****.net/wangnaisheng/article/details/32330857