string resourceurl = ((LinkButton)sender).CommandArgument.ToString();
try
{
int i = resourceurl.LastIndexOf('\\');
string filename=resourceurl.Substring(i + 1);
string FullFileName = Server.MapPath(resourceurl);
FileInfo DownloadFile = new FileInfo(FullFileName);
if (DownloadFile.Exists)
{
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.ASCII));
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
else
{
ClientScript.RegisterStartupScript(GetType(),"alert","alert('文件不存在!')",true);
}
}
catch
{
throw;
}
try
{
int i = resourceurl.LastIndexOf('\\');
string filename=resourceurl.Substring(i + 1);
string FullFileName = Server.MapPath(resourceurl);
FileInfo DownloadFile = new FileInfo(FullFileName);
if (DownloadFile.Exists)
{
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.ASCII));
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
else
{
ClientScript.RegisterStartupScript(GetType(),"alert","alert('文件不存在!')",true);
}
}
catch
{
throw;
}