给你提供一点代码:
string fileURL = this.Server.MapPath("你要下载的文件路径")//文件路径,可用相对路径
FileInfo fileInfo = new FileInfo(fileURL)
Response.Clear()
Response.AddHeader("content-disposition", "attachmentfilename=" +
Server.UrlEncode(fileInfo.Name.ToString()))//文件名
Response.AddHeader("content-length", fileInfo.Length.ToString())//文件大小
Response.ContentType = "application/octet-stream"
Response.ContentEncoding = System.Text.Encoding.Default
Response.WriteFile(fileURL)
给你提供一点代码:string fileURL = this.Server.MapPath("你要下载的文件路径")//文件路径,可用相对路径
FileInfo fileInfo = new FileInfo(fileURL)
Response.Clear()
Response.AddHeader("content-disposition", "attachmentfilename=" + Server.UrlEncode(fileInfo.Name.ToString()))//文件名
Response.AddHeader("content-length", fileInfo.Length.ToString())//文件大小
Response.ContentType = "application/octet-stream"
Response.ContentEncoding = System.Text.Encoding.Default
Response.WriteFile(fileURL)
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)