关于response.addheader中文文件名的问题
偶用response.addheader下载附件。如果是中文文件名,另存为的时候文件名就变成乱码。偶怀疑是编码的问题,可是不知道怎么修改。偶只有30分了,全部送了。谢谢大家。
附源码
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string filename ="C:\\Inetpub\\wwwroot\\Menu\\中国.doc";
string name="中国";
long FileSize;
System.IO.FileStream PrintStream = new System.IO.FileStream(filename,System.IO.FileMode.Open);
FileSize = PrintStream.Length;
byte[] Buffer = new byte[(int)FileSize];
PrintStream.Read(Buffer, 0, (int)PrintStream.Length);
PrintStream.Close();
Response.ContentType="application/msword";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.AddHeader("content-disposition","attachment; filename=\""+name+"\"");
Response.BinaryWrite(Buffer);
Response.Flush();
Response.Close();
}