下载对话框的实现
来源:互联网 发布:网络运营师要考证吗 编辑:程序博客网 时间:2024/05/23 19:15
protected void lbtnDownload_Command(object sender, CommandEventArgs e)
{
BllDYPolicy bll = new BllDYPolicy();
int fileId = Convert.ToInt32(e.CommandArgument);
bool isSuccess = true;
DataSet ds = bll.GetList(fileId);
string filepath = ds.Tables[0].Rows[0]["filepath"].ToString();
string filesourcename = ds.Tables[0].Rows[0]["filesourcename"].ToString();
string extensionName = filepath.Substring(filepath.LastIndexOf("."));
string fileName = String.Format("attachment; filename=/"{0}{1}/"", HttpUtility.UrlEncode(filesourcename), extensionName);
string path = Server.MapPath(this._mainPath + filepath);
try
{
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", fileName);
Response.AddHeader("Content-Length", fs.Length.ToString());
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
Response.BinaryWrite(buffer);
}
catch (Exception ex)
{
isSuccess = false;
Context.Response.ClearHeaders();
Context.Response.Clear();
Context.Response.ContentType = "text/html";
//Context.Response.Write("<script>alert('" + ex.Message + "');</script>");
JSUtility.Alert(ex.Message);
}
if (isSuccess) Context.Response.End();
}
- 下载对话框的实现
- JS实现弹出下载对话框及常见文件类型的下载
- 自动更新--下载apk以及提示对话框的实现(3)
- Cordova插件实现文件下载对话框
- 浏览对话框的实现
- 实现对话框的伸缩
- 对话框的MVVM实现
- 弹出对话框的实现
- 定时对话框的实现
- alertDialog对话框的实现
- 动态对话框的实现
- 对话框的实现
- Android对话框的实现
- java 实现文件下载的时候,避免浏览器自动打开文件,而是出现另存为对话框
- 定制IE下载对话框的按钮
- PHP:设置文件下载对话框的文件名
- 定制IE下载对话框的按钮
- 各种对话框的实现(文字对话框,选择对话框,弹出输入对话框,单选,多选对话框,自定义对话框)
- 开源----java软件的选择
- MSN在线状态显示脱机故障恢复 与推新版无关
- Using Timer to get history values from EDNA database, an error is prompted in the page : "Sys.WebForms.PageRequestManagerTimeout
- Delphi 和Foxpro整合实现txt和dbf互相转换
- 递归算法
- 下载对话框的实现
- oracle建立用户、数据库对象的过程
- 获取当前月的第一天和最后一天
- 格式化字符串至调试窗口
- VC通过位图,来实现Slider控件
- EXT基本语法
- JAVA WebService实例
- 【SQLServer】SQL的本月统计、本周统计和本季度统计
- Sybase: Say Yes to Be A Sybase Employee (Part2)