不让 IE 打开txt
rt
就是希望 在IE 中打开 txt 文件时,实现 下载 该txt文件 或 把这个txt文件 另存为 这个功能
问题点数:30、回复次数:2Top
1 楼minajo21(大眼睛)回复于 2006-03-09 13:17:16 得分 20
不能直接超连 .txt 文件的地址。
参考:
string strPathServer = this.p_strFtpFilePath + "\\";
string strFileServerName = e.Item.Cells[4].Text;
string contentType = "application/";
string strFileSaveName = ((LinkButton)e.Item.FindControl("BtnAttachName")).Text;
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
diskOpts.DiskFileName = strPathServer + strFileServerName;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset ="GB2312";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + strFileSaveName);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.ContentType = contentType;
HttpContext.Current.Response.WriteFile(diskOpts.DiskFileName);
HttpContext.Current.Response.End();Top
2 楼abandonship(焚酒煮剑)回复于 2006-03-09 13:29:31 得分 10
搜一下下载机制吧,把文件流读出,当你点保存时已经流形式保存Top




