如何隐藏下载路径---急

freddy2003 2005-11-28 07:32:01
我有一写重要的access文件让用户下载。文件名是动态的。不能用<a></a>这种
在网上找了一段代码

public static void FileDownload(string FullFileName)
{
//FileInfo Driver_Path = new FileInfo(FullFileName);
string Driver_Path=HttpContext.Current.Server.MapPath(".")+"\\DownLoad\\"+FullFileName;
if (!File.Exists(Driver_Path))
{
HttpContext.Current.Response.Write("<script>window.alert('文件不存在!')</script>");
return;
}


try
{
FileInfo file1 = new FileInfo(Driver_Path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.Buffer = false;
string strHadFileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(Driver_Path));
HttpContext.Current.Response.AddHeader("Content-Type","application/octet-stream");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + strHadFileName); //下载到客户端默认文件名
// 可以看到下载进程
HttpContext.Current.Response.AddHeader("Content-Length", file1.Length.ToString());
string strFullName = file1.FullName;
HttpContext.Current.Response.WriteFile(strFullName);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
catch
{


}
}



调用:

private void Button2_Click(object sender, System.EventArgs e)
{
string file1="API_IDECL_DBF.mdb";
Interface.FileDownload(file1);
}

但在下载的时候,有个用户提示框,显示文件的路径,我想这不太安全。

请问有没有办法,不让用户提示框的文件路径显示出来?
...全文
292 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
freddy2003 2005-11-29
  • 打赏
  • 举报
回复
To:truelove12(醉倒在巷口)
能不能讲详细一点。谢谢
freddy2003 2005-11-29
  • 打赏
  • 举报
回复
up
  • 打赏
  • 举报
回复
你可以使用webclient.直接下载到客户端的指定位置。
hainang1234 2005-11-28
  • 打赏
  • 举报
回复
没有

62,074

社区成员

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

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

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

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