孟老大
在客户端浏览各类文档,使用超链接方式,文件流方式都会有下载提示,我希望在IE中直接打开,没有下载提示如何实现?谢谢!下面是我目前使用的代码string path = Server.MapPath(fileInfo_Path);
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] MyData = new byte[fileStream.Length];
fileStream.Read(MyData, 0, System.Convert.ToInt32(fileStream.Length));
fileStream.Close(); this.Response.Clear();
this.Response.ClearHeaders();
this.Response.Buffer = true;
this.Response.ContentType = contentType;
this.Response.Expires = -1;
this.Response.AppendHeader("Content-Language", "zh");
this.Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(file_name, System.Text.Encoding.UTF8));
Response.ContentEncoding = System.Text.Encoding.Default;
this.Response.BinaryWrite(MyData);
this.Response.Flush();
this.Response.End();
在客户端浏览各类文档,使用超链接方式,文件流方式都会有下载提示,我希望在IE中直接打开,没有下载提示如何实现?谢谢!下面是我目前使用的代码string path = Server.MapPath(fileInfo_Path);
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] MyData = new byte[fileStream.Length];
fileStream.Read(MyData, 0, System.Convert.ToInt32(fileStream.Length));
fileStream.Close(); this.Response.Clear();
this.Response.ClearHeaders();
this.Response.Buffer = true;
this.Response.ContentType = contentType;
this.Response.Expires = -1;
this.Response.AppendHeader("Content-Language", "zh");
this.Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(file_name, System.Text.Encoding.UTF8));
Response.ContentEncoding = System.Text.Encoding.Default;
this.Response.BinaryWrite(MyData);
this.Response.Flush();
this.Response.End();
解决方案 »
- 用C#做一个窗体应用程序,含有datagridview控件,现添加一CellDoubleClick事件,想修改单元格内容更新数据库。
- crystal report 里怎么设置小数点位数呢
- 请问,这种随机抽取怎么做
- C#简单问题求解
- 求助:C#生成二叉树代码错在哪里?
- C# 把文字画在图片中。。。文字无法正常显示要求大小
- 请问怎样把byte[]转化为stream?
- 如何在一张图片上面输出文字?文字要显示在图片的中央对齐,谢谢!
- 一个关于int转换成string的问题
- 各位老大,帮帮忙,可能是数据库连接的问题,花了几百分了,还没搞定呀。。帮顶的都有分
- 关于周期提醒的问题?
- .net串行端口通信问题,着急
string path = Server.MapPath(fileInfo_Path);
FileInfo DownloadFile = new FileInfo(path);
this.Response.Clear();
this.Response.ClearHeaders();
this.Response.Buffer = true;
this.Response.ContentType = contentType;
this.Response.Expires = -1;
this.Response.AppendHeader("Content-Language", "zh");
this.Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(file_name, System.Text.Encoding.UTF8));
Response.ContentEncoding = System.Text.Encoding.Default;
this.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
this.Response.WriteFile(DownloadFile.FullName);
this.Response.Flush();
this.Response.End();我这样写也是有下载提示