超链接打开文件乱码

sshh00 2010-10-22 10:22:46
我上传了一个文件放在 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页面上就显示的是乱码了。
请各位高手帮忙解决下,谢谢了。
...全文
396 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sshh00 2010-12-10
  • 打赏
  • 举报
回复
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 );
}
}
sshh00 2010-12-10
  • 打赏
  • 举报
回复
CICollectors.cs
sshh00 2010-10-22
  • 打赏
  • 举报
回复
rar文件也不行啊,我上传的时候直接用fileupload的saveAs保存的
wuyq11 2010-10-22
  • 打赏
  • 举报
回复
保护的,压缩cs,下载压缩文件
FocusNT 2010-10-22
  • 打赏
  • 举报
回复
那就是你想让别人下载这个页面?
用流读取...
或者给他打个RAR吧
孟子E章 2010-10-22
  • 打赏
  • 举报
回复
cs文件是受保护的,不能直接访问,你可以采用 StreamReader = d = new StreamReader(path,Encoding.GetEncoding("GB2312"))

d.ReadToEnd()读取
sshh00 2010-10-22
  • 打赏
  • 举报
回复
简单的说,就是用fileupload上传文件,用超链接显示,点击超链接可以打开或者下载该文件,但是我现在这个不知道怎么会出现乱码了,打不开
sshh00 2010-10-22
  • 打赏
  • 举报
回复
在页面上显示101021000004.cs这个文件,或者上传的doc、txt文件的内容
cpp2017 2010-10-22
  • 打赏
  • 举报
回复
如果是你做个显示.cs文件的页面,这应该是浏览器编码没有自动切换的问题.
cpp2017 2010-10-22
  • 打赏
  • 举报
回复
你需要在网页上显示源码的内容吗?

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧