不会吧,txt文件正常的,就是word有问题

解决方案 »

  1.   

    你要用GB2312格式来存到数据库,然后读出来的时候再转换成GB2312,这样估计就没有问题了。
    我也碰到这样的问题的。
      

  2.   

    你要用GB2312格式来存到数据库,然后读出来的时候再转换成GB2312,这样估计就没有问题了
      

  3.   

    Response.Clear();
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(filename));
    Response.ContentEncoding = System.Text.Encoding.Default;
    Response.ContentType = dr["doctype"].ToString();
    Response.Charset = "gb2312";
    Response.BinaryWrite((byte[])dr["doc"]);
    Response.Flush();
    Response.Close();
    Response.End();
      

  4.   

    using   System; 
    using   System.Data; 
    using   System.Configuration; 
    using   System.Collections; 
    using   System.Web; 
    using   System.Web.Security; 
    using   System.Web.UI; 
    using   System.Web.UI.WebControls; 
    using   System.Web.UI.WebControls.WebParts; 
    using   System.Web.UI.HtmlControls; 
    using   System.IO; 
    public   partial   class   Admin_Contact_Download   :   AdminBase 

            protected   void   Page_Load(object   sender,   EventArgs   e) 
            {         从数据库中读出数据   表结构为     ID,Type(varchar(50)),Attachment(image()) 
                    
                      对象m 
                    m.Attachment   是文件内容是   byte[] 
                    m.Type   是文件的扩展名, 
                    string   Type   =   checktype(m.Type); 
                    Response.Clear(); 
                    Response.AddHeader( "Content-Disposition ",   "attachment;   filename= "   +   HttpUtility.UrlEncode( "附件 "   +   m.Type));                 Response.AddHeader( "Content-Length ",   m.Attachment.Length.ToString()); 
                    Response.ContentType   =   "application   /   msword ";   // "application/octet-stream ";                 Response.BinaryWrite(m.Attachment); 
                    Response.End(); 
                    string   FileName   =   ((LinkButton)sender).CommandArgument; 
                    Response.Clear(); 
                    Response.ContentType   =   "application/msword ";//   "application/octet-stream "; 
                    Response.AddHeader( "Content-Disposition ",   "attachment;FileName= "   +   HttpUtility.UrlEncode(FileName,   System.Text.Encoding.UTF8)); 
                    Response.WriteFile(FileName); 
                    Response.End(); 
            }         private   string   checktype(string   filename) 
            { 
                    string   ContentType; 
                    switch   (filename.Substring(filename.LastIndexOf( ". ")).Trim().ToLower()) 
                    { 
                            case   ".asf ": 
                                    ContentType   =   "video/x-ms-asf "; 
                                    break; 
                            case   ".avi ": 
                                    ContentType   =   "video/avi "; 
                                    break; 
                            case   ".doc ": 
                                    ContentType   =   "application/msword ";   break; 
                            case   ".zip ": 
                                    ContentType   =   "application/zip ";   break; 
                            case   ".xls ": 
                                    ContentType   =   "application/vnd.ms-excel ";   break; 
                            case   ".gif ": 
                                    ContentType   =   "image/gif ";   break; 
                            case   ".jpg ": 
                                    ContentType   =   "image/jpeg ";   break; 
                            case   "jpeg ": 
                                    ContentType   =   "image/jpeg ";   break; 
                            case   ".wav ": 
                                    ContentType   =   "audio/wav ";   break; 
                            case   ".mp3 ": 
                                    ContentType   =   "audio/mpeg3 ";   break; 
                            case   ".mpg ": 
                                    ContentType   =   "video/mpeg ";   break; 
                            case   ".mepg ": 
                                    ContentType   =   "video/mpeg ";   break; 
                            case   ".rtf ": 
                                    ContentType   =   "application/rtf ";   break; 
                            case   ".html ": 
                                    ContentType   =   "text/html ";   break; 
                            case   ".htm ": 
                                    ContentType   =   "text/html ";   break; 
                            case   ".txt ": 
                                    ContentType   =   "text/plain ";   break; 
                            default: 
                                    ContentType   =   "application/octet-stream "; 
                                    break; 
                    } 
                    return   ContentType; 
            }