62,046
社区成员
发帖
与我相关
我的任务
分享
string fileName = ds.Tables[0].Rows[0]["FilePath"].ToString();//服务器保存的文件名
string temppath = Request.PhysicalApplicationPath + "User//UpLoad//data//";//上传路径
string filePath = temppath + fileName;
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();