BoYu045535
public void DownLoad( )
{
string filePath = Server.MapPath( @"\UserFile\" );//这里注意了,你得指明要下载文件的路径.

if ( System.IO.File.Exists( filePath ) )
{
FileInfo file = new FileInfo( filePath );
Response.ContentEncoding = System.Text.Encoding.GetEncoding( "UTF-8" ); //解决中文乱码
Response.AddHeader( "Content-Disposition", "attachment; filename=" + Server.UrlEncode( file.Name ) ); //解决中文文件名乱码
Response.AddHeader( "Content-length", file.Length.ToString() );
Response.ContentType = "appliction/octet-stream";
Response.WriteFile( file.FullName );
Response.End();
}
}

分类:

技术点:

相关文章:

  • 2021-06-01
  • 2021-12-26
  • 2021-08-16
  • 2021-12-10
猜你喜欢
  • 2021-09-08
  • 2021-07-09
  • 2021-09-08
  • 2021-11-14
  • 2022-12-23
  • 2021-09-08
  • 2021-09-08
相关资源
相似解决方案