用 OnCommand事件怎么没反应,错也不报
protected void DownLoadBtn_Command(object sender,CommandEventArgs e)
{
if (e.CommandName == "DownLoad")
{
DataSet ds = bll_FileMan.CheckIsFile(RootID);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
string path = Session["FolderPath"] + ds.Tables[0].Rows[0]["FileName"].ToString();
FileInfo fi = new FileInfo(path);
if (fi.Exists)
{
Response.AddHeader("content-type", "application/x-msdownload"); Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(fi.Name))); Response.Flush();
}
FileStream streamFile = File.OpenRead((Session["FolderPath"] + "/" + ds.Tables[0].Rows[0]["FileName"].ToString())); byte[] byteFile = new byte[streamFile.Length]; streamFile.Read(byteFile, 0, int.Parse(streamFile.Length.ToString())); Response.BinaryWrite(byteFile); Response.End();
}
}
}
protected void DownLoadBtn_Command(object sender,CommandEventArgs e)
{
if (e.CommandName == "DownLoad")
{
DataSet ds = bll_FileMan.CheckIsFile(RootID);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
string path = Session["FolderPath"] + ds.Tables[0].Rows[0]["FileName"].ToString();
FileInfo fi = new FileInfo(path);
if (fi.Exists)
{
Response.AddHeader("content-type", "application/x-msdownload"); Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(fi.Name))); Response.Flush();
}
FileStream streamFile = File.OpenRead((Session["FolderPath"] + "/" + ds.Tables[0].Rows[0]["FileName"].ToString())); byte[] byteFile = new byte[streamFile.Length]; streamFile.Read(byteFile, 0, int.Parse(streamFile.Length.ToString())); Response.BinaryWrite(byteFile); Response.End();
}
}
}
解决方案 »
- 如何在IE关闭的时候,发出提示
- 如何验证windows AD域账户登录到WEB页面
- 请问使用AJAX有什么好处?
- 关于相对路径(使用根目录上一级的路径)
- 帮忙呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 求权限委托的解决思路?在传统的权限设置基础之上
- 高分请进:File控件保存文件的问题,Asp.NET怎么保存一个文件到局域网的另一台机?
- 如何建设一个.net站点?来讲讲!散分!
- ASP.net的新手
- 新手问题!
- 怎么在发贴加入表情下拉及加入快速插入代码图标
- 如果用程序设定Server2008里面IIS的ISAPI and CGI
protected void DownLoadBtn_Command(object sender,CommandEventArgs e)
{
if (e.CommandName.Equals("DownLoad"))
{
DataSet ds = bll_FileMan.CheckIsFile(RootID);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
string path = Session["FolderPath"] + ds.Tables[0].Rows[0]["FileName"].ToString();
FileInfo fi = new FileInfo(path);
if (fi.Exists)
{
Response.AddHeader("content-type", "application/x-msdownload"); Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(fi.Name))); Response.Flush();
}
FileStream streamFile = File.OpenRead((Session["FolderPath"] + "/" + ds.Tables[0].Rows[0]["FileName"].ToString())); byte[] byteFile = new byte[streamFile.Length]; streamFile.Read(byteFile, 0, int.Parse(streamFile.Length.ToString())); Response.BinaryWrite(byteFile); Response.End();
}
}
}