请教各位大大,小第把附件存在数据库中,用户点击链接下载附件时,原来很长的中文文件名一律都变成16个中文了,163的附件下载似乎没有这个限制,请问各位大大该如何解决

解决方案 »

  1.   

    设置web.config中:
    <globalization
    requestEncoding="gb2312"
        responseEncoding="gb2312"
    />
      

  2.   

    我是把存在数据库里的文件先变成文件流然后存成一个临时文件,然后跳转到这个文件,它就会弹出一个下载的对话框
    代码:
    FileStream fs =new FileStream(MapPath("temp/"+dr.GetString(1).ToString()),FileMode.Create);
    fs.Read(Buffer,0,Buffer.Length);
    fs.Close();
    Response.Redirect("temp/"+dr.GetString(1).ToString());
      

  3.   

    可是Response.Redirect以后原来很长的中文文件名就变成只有16个中文字了
      

  4.   

    试试Server.UrlEncode和Server.UrlDecode
      

  5.   

    try
    {
    if(conn.State==ConnectionState.Closed)
    conn.Open();
    SqlDataReader dr=cmd.ExecuteReader();
    while(dr.Read())
    {
    HttpContext.Current.Response.Buffer=true;
    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.ContentType=dr["filetypes"].ToString();
    HttpContext.Current.Response.AddHeader("Content-Type",dr["filetypes"].ToString());
    HttpContext.Current.Response.AddHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(dr["fileName"].ToString())+";");
    HttpContext.Current.Response.BinaryWrite((byte[])dr["filecontent"]);
    HttpContext.Current.Response.Flush();
    HttpContext.Current.Response.End();
    }
    }
    catch
    {
    throw;
    }
    finally
    {
    conn.Close();
    }
      

  6.   

    保存时没有被截断,是IE的问题,似乎IE会把字符截取,但163邮箱的附件可以不知道为什么