对附件的处理是存放在数据库中,下载时,使用的是以下方法:
this.Response.Buffer=true;
this.Response.Clear();
string filefjm=mycls.ds.Tables[0].Rows[0]["fjm"].ToString();
string ext=filefjm.Substring(filefjm.LastIndexOf("."));
this.Response.ContentType = Convert.ToString(mycls.ds.Tables[0].Rows[0]["filetype"].ToString());
this.Response.AddHeader("Content-Disposition:", "attachment; filename=temp" + ext);//filename=" + HttpUtility.UrlEncode(mycls.ds.Tables[0].Rows[0]["fjm"].ToString()));
object dbValue = mycls.ds.Tables[0].Rows[0]["fujian"];
byte[] file = (byte[])dbValue;
this.Response.BinaryWrite(file);
this.Response.Flush();
this.Response.Clear();
this.Response.End();
在XPSP2_gdr这个版本上,this.Response.AddHeader("Content-Disposition:", "attachment; filename=temp" + ext);英文和数字作为下载时的文件名时没有问题的,但是下载时的文件使用中文,就会出现这样一个问题,在出现“打开”、“保存”、“取消”窗口时,无论点击哪个按钮,窗口后面的空白页面都不会关闭,必须手工关闭。
而在其他系统或者xpsp2_rtm这个版本上不出现整个情况。
哪位高手能解决这个问题,谢谢!!!
this.Response.Buffer=true;
this.Response.Clear();
string filefjm=mycls.ds.Tables[0].Rows[0]["fjm"].ToString();
string ext=filefjm.Substring(filefjm.LastIndexOf("."));
this.Response.ContentType = Convert.ToString(mycls.ds.Tables[0].Rows[0]["filetype"].ToString());
this.Response.AddHeader("Content-Disposition:", "attachment; filename=temp" + ext);//filename=" + HttpUtility.UrlEncode(mycls.ds.Tables[0].Rows[0]["fjm"].ToString()));
object dbValue = mycls.ds.Tables[0].Rows[0]["fujian"];
byte[] file = (byte[])dbValue;
this.Response.BinaryWrite(file);
this.Response.Flush();
this.Response.Clear();
this.Response.End();
在XPSP2_gdr这个版本上,this.Response.AddHeader("Content-Disposition:", "attachment; filename=temp" + ext);英文和数字作为下载时的文件名时没有问题的,但是下载时的文件使用中文,就会出现这样一个问题,在出现“打开”、“保存”、“取消”窗口时,无论点击哪个按钮,窗口后面的空白页面都不会关闭,必须手工关闭。
而在其他系统或者xpsp2_rtm这个版本上不出现整个情况。
哪位高手能解决这个问题,谢谢!!!
{
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
// 把文件流发送到客户端
Response.WriteFile(file.FullName);
// 停止页面的执行
Response.End();
}
catch
{ }