用asp.net来实现文件下载代码如下所示:
string path=Server.MapPath(@"/dlia/download/")+filepath+"\\"+(string)filename;
System.IO.FileInfo theFile = new System.IO.FileInfo( path );
Response.Clear();
Response.AddHeader("Content-Disposition","attachment; filename=" + theFile.Name);
Response.AddHeader("Content-Length",theFile.Length.ToString());
Response.ContentType="application/octet-stream";
Response.WriteFile(theFile.FullName);
Response.End();
出现一个问题就是如果filename是中文,下载之后显示乱码,请教一下应该怎么解决?