昨天测试了下载文家名称的长度,可是文件名称过长的话(具体是超过17个)就会出现乱码。
由于系统的需求文件名称是肯定会超过17个的
不知道那位高人指点下了

解决方案 »

  1.   

    http://blog.csdn.net/hglxr/archive/2008/01/10/2034080.aspx
    http://www.cnblogs.com/bobowu/archive/2005/08/14/214580.html
      

  2.   

    文件长度超过17没问题,应该是代码问题
      string path = Server.MapPath("~/") +"";
     Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(obj.Name, System.Text.Encoding.GetEncoding("utf-8"))  + "." + obj.AttachmentExt);//HttpUtility.UrlEncode                    if (File.Exists(path))
                        {
                            Response.ContentType = "application/octet-stream";
                            Response.WriteFile("" + path + "");
                        }
                        Response.End();
      

  3.   

    对文件名字进行UTF-8编码
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("UTF-8","文件名");
      

  4.   

       Response.Clear();
                Response.ClearHeaders();
                Response.Buffer = false;
                string FileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(_lf.filename));
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(_lf.filename, System.Text.Encoding.GetEncoding("utf-8")));
                Response.WriteFile(Server.MapPath("~/LawFile/") + _lf.savename);
                Response.Flush();
      

  5.   

    不是吧  现在csdn的人这么保守吗?都不愿意说?还是没人会