我上传了一个文件放在 D:\GLOA\Department\101021000003\101021000004.cs这个位置,
gridview中用模板显示
<asp:TemplateColumn HeaderText="原文件名">
<ItemTemplate>
<asp:HyperLink runat="server" NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.File_Path", "/{0}") %>'
Target="_blank" Text='<%# DataBinder.Eval(Container, "DataItem.File_Name") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
页面超链接指向地址如下:http://localhost:2813/Department/101021000003/101021000004.cs
但是点开后IE页面上就显示的是乱码了。
请各位高手帮忙解决下,谢谢了。

解决方案 »

  1.   

    在页面上显示101021000004.cs这个文件,或者上传的doc、txt文件的内容
      

  2.   

    简单的说,就是用fileupload上传文件,用超链接显示,点击超链接可以打开或者下载该文件,但是我现在这个不知道怎么会出现乱码了,打不开
      

  3.   

    cs文件是受保护的,不能直接访问,你可以采用 StreamReader = d = new StreamReader(path,Encoding.GetEncoding("GB2312"))d.ReadToEnd()读取
      

  4.   

    那就是你想让别人下载这个页面?
    用流读取...
    或者给他打个RAR吧
      

  5.   

    rar文件也不行啊,我上传的时候直接用fileupload的saveAs保存的
      

  6.   

    protected Dictionary<string, string> CIInfoList;
    protected Dictionary<string, string> CIDataList;
    protected Dictionary<string, string> CITimeDataList;
    protected Dictionary<string, string> CIBuildDataList;
    protected List<string> FileList;
    protected ReadConfigData ConfigData;
    protected CICollectors.Entry.Log CILog;
    protected string LogPath;
    protected string LogFileName;
            protected string ConfigFilePath;
    protected string ReportFileName; public CICollector()
    { }        public CICollector( string LogPath, string LogFileName, string ConfigFilePath )
            {
                CIInfoList = new Dictionary<string, string>();
                CIDataList = new Dictionary<string, string>();            this.LogPath = LogPath;
                this.LogFileName = LogFileName;
                this.ConfigFilePath = ConfigFilePath;        }        public void RunCollector()
            {
                if( IsPathError() )
                {
                    return;
                }
                if( IsFileNameError() )
                {
                    return;
                }
                if( IsParseConfigFileFail() )
                {
                    return;
                }
                CIInfoList.Add( "pdu", ConfigData.PDUInfo );
                CIInfoList.Add( "version", ConfigData.VersionInfo );
                CIInfoList.Add( "projectteam", ConfigData.ProjectTeamInfo );            //执行log信息
                if( IsParseLogFail() )
                {
                    return;
                }
                GetCIInfoFromLogFile();
                CITimeDataList = new Dictionary<string, string>( this.CIDataList );
                CIDataList.Clear();
                GetCIInfoFromUserPlugin();
                GetCIInfoFromCommonPlugin();
                CIBuildDataList = new Dictionary<string, string>( this.CIDataList );
                SetReportFileName();            
    #if DEBUG    
                Console.WriteLine("Debug: Don't create xml file,Don't update ftp file.");
    #else
                CreateCIXML obj = new CreateCIXML( this.ReportFileName, CIInfoList, CITimeDataList, CIBuildDataList );
                UpFile();
    #endif
            } protected void UpFile()
            {
                try
                {
                    FTPClient cilent = new FTPClient();
                    cilent.Upload( Directory.GetCurrentDirectory() + "\\" + this.ReportFileName );
    FileInfo file = new FileInfo(Directory.GetCurrentDirectory() + "\\" + this.ReportFileName);
    if (file.Exists)
    {
    file.Delete(); //删除单个文件
    }
                    ////ftpClient.Put(Directory.GetCurrentDirectory() + "\\" + outputname);
                    //bool flag = FtpUpload("", "cihandler", "cihandler", "aphi.huawei.com.cn", Directory.GetCurrentDirectory() + "\\" + this.ReportFileName, this.ReportFileName);
                    //if (flag)
                    //{
                    //    Console.WriteLine("Upload file '{0}' success.", this.ReportFileName);
                    //    FileInfo file = new FileInfo(Directory.GetCurrentDirectory() + "\\" + this.ReportFileName);
                    //    if (file.Exists)
                    //    {
                    //        file.Delete(); //删除单个文件
                    //    }
                    //}
                    //else
                    //{
                    //    Console.WriteLine("Upload file '{0}' failed.", Directory.GetCurrentDirectory() + "\\" + this.ReportFileName);
                    //}
                }
                catch( Exception ex )
                {
                    Console.WriteLine( "Upload file '{0}' failed!", Directory.GetCurrentDirectory() + "\\" + this.ReportFileName );
                    Console.WriteLine( "捕获到的异常信息:" + ex.Message );
                }
            }