请各位大神帮忙,字符串在内存中生成txt格式文件并弹出另存为窗口 字符串 内存流 流生成文件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接生成输出的。http://blog.sina.com.cn/s/blog_7d7e7a670100sdqx.html 没有弹出另存为的对话框 Response.Clear(); Response.Buffer = true; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=PhoneNo.txt"); Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "text/plain"; //设置输出文件类型为txt文件。 this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true); StringWriter oStringWriter = new StringWriter(myCItrad);(这个是设置什么的,没用上啊) Response.Write(sb.ToString()); Response.End(); 自己写的用于下载文件的公共函数,供参考: public static void DownloadFile(HttpResponse response, string fileContent, string fileName) { MemoryStream ms = new MemoryStream(); ms.Write(new byte[] { 0xEF, 0xBB, 0xBF }, 0, 3); var fileBytes = System.Text.Encoding.UTF8.GetBytes(fileContent); ms.Write(fileBytes, 0, fileBytes.Length); ms.Close(); response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); response.ContentType = "application/octet-stream"; response.BinaryWrite(ms.ToArray()); response.End(); } 尝试对参数 http://tempuri.org/ 进行序列化时出错 一个ASPX关键字获取的问题 asp:FileUpload小问题求助 问一个非技术性的问题关于域名 一个ACCESS数据库的问题! 关于net2.0保存cookie的问题,没分了,但是一定加! 请教:如何提取网页中指定两段代码中间的字符?在线等 树形菜单的问题 (在线等待) 为刚刚建成的社区送分100,想要的朋友来呀 怎样用ftp上传文件在brinkster上啊 win7下安裝vs2010新建项目空白,新建网站报调用目标发生异常 【被人黑了,求助】求大神看看这个是什么数据库工具。
http://blog.sina.com.cn/s/blog_7d7e7a670100sdqx.html
没有弹出另存为的对话框
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=PhoneNo.txt");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/plain"; //设置输出文件类型为txt文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
StringWriter oStringWriter = new StringWriter(myCItrad);(这个是设置什么的,没用上啊)
Response.Write(sb.ToString());
Response.End();
public static void DownloadFile(HttpResponse response, string fileContent, string fileName)
{
MemoryStream ms = new MemoryStream();
ms.Write(new byte[] { 0xEF, 0xBB, 0xBF }, 0, 3);
var fileBytes = System.Text.Encoding.UTF8.GetBytes(fileContent);
ms.Write(fileBytes, 0, fileBytes.Length);
ms.Close(); response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
response.ContentType = "application/octet-stream";
response.BinaryWrite(ms.ToArray());
response.End();
}