//string fileName = "ceshi.rar";//客户端保存的文件名 //string filePath = Server.MapPath("keji.rar");//路径 //路径 string filePath = Server.MapPath("~/DownLoadFileTemp/" + this.FileUrl.Text); string fileName = this.FileUrl.Text;
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();