点击按钮自动弹出对话框自定义地址来保存图片,图片的获取没问题,可就是死活不出对话框。大假帮我看看是什么问题啊
<anthem:Button ID="btnDwload" runat="server" TextDuringCallBack="downloading..." EnabledDuringCallBack="false"Text="下载照片" OnClick="btnDwload_Click" CssClass="button_a" />
FileInfo DownloadFile = new FileInfo(strPhotoPath);
//strPhotoPath是图片的地址,没有错误的
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream ";
Response.AppendHeader("Content-Disposition ", "attachment;filename= "
+ HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length ", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
<anthem:Button ID="btnDwload" runat="server" TextDuringCallBack="downloading..." EnabledDuringCallBack="false"Text="下载照片" OnClick="btnDwload_Click" CssClass="button_a" />
FileInfo DownloadFile = new FileInfo(strPhotoPath);
//strPhotoPath是图片的地址,没有错误的
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream ";
Response.AppendHeader("Content-Disposition ", "attachment;filename= "
+ HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length ", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
解决方案 »
- 在线等!求助,devexpress怎么能程序运行后鼠标任何调整控件大小?
- 为什么窗体关闭之后还可以访问?
- 一句很简单的代码 为什么错了
- 高分求向各位高手帮助
- 关于 statusstrip 控件右下角小手柄,SizingGrip=false 但那一小正方块仍存在,向高手们求救~!~!~!
- 如何判断一个字符是否是中文?
- C# mysql的问题
- 怎么使一个窗体只能被实例化一次
- 60分问个弱智问题:知道文件的IntPtr句柄,怎样获得该文件的路径?
- 关于连接SQL数据库问题!
- |zyciis| 如何设置SqlConnection.Open()的超时时间为5秒呢
- 有空的高手一定要帮忙看看。。。关于级联删除TreeView 节点的问题。。在线等。
protected void Button1_Click(object sender, EventArgs e)
{
FileInfo fi = new FileInfo(@"c:\1.gif");
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fi.Name));
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.WriteFile(fi.FullName);
Response.Flush();
Response.End();
}
上面的代码测试OK,你自己看看吧