62,046
社区成员
发帖
与我相关
我的任务
分享
if (FileID != 0)
{
string FileName = GetFileName(FileID);//FileUrl.Remove(0, 11);
string fileName = FileName;
string filePath = Server.MapPath("uploads/file/" + FileName);
if (File.Exists(filePath) == true)
{
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();
}
else
{
Response.Write("您所查找的文件不存在!");
}
}
else
{
Response.Write("地址非法!");
}