Word文件直接打开问题
file_name = HttpUtility.UrlEncode(Replace(file_name.Trim, " ", ""), System.Text.Encoding.UTF8)
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/octet-stream"
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" & file_name)
HttpContext.Current.Response.BinaryWrite(wjData)
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
End Function
如上代码,如果在链接上点右键 另存为 文件名是中文,如果直接接打开的话 文件名是类似
%e5%8d%8e%e5%ba%9c%e5%ae%b6%e5%9b%ad%e6%88%b7%e5%86%85%e7%ae%a1%e7%87%83%e6%b0%94%e5%b7%a5%e7%a8%8b%e5%b7%a5%e7%a8%8b-04-X062-4[1].doc
这样的话会导致文件名加上temp目录的路径名过长,使word打开时出错。请问在不缩短文件名的前提下应该怎么做?