asp.net中要怎么做才能把服务器上的东西下载下来

时间:2022-02-21 17:19:53
我做的是一个毕业设计管理系统
当学生把相关文件都传到服务器上后,老师可以从服务器上把这些文件下载下来看
这要怎么做呢?
请各位帮帮忙,先谢谢了。

10 个解决方案

#1


用超级链接不就可以了吗

#2


用超级链接怎么做,我用了不行

#3


<a href="文件全路径">下载</a>

#4



private void FileDownload(string FullFileName)
  {
   FileInfo DownloadFile = new FileInfo(FullFileName);
   Response.Clear();
   Response.ClearHeaders();
   Response.Buffer = false;
   Response.ContentType ="application/octet-stream";
   Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
            Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
   Response.WriteFile(DownloadFile.FullName);
   Response.Flush();
   Response.End();
  } 

#5



<a href="http://www.wowchina.com/download/client/index.shtml?2030" target="_blank">2.2.3到2.3.0升级补丁</a>

#6


弄个超级链接,那要怎么把数据库中的路径绑定到这个超级链接,NavigateUrl要设成什么

#7


顶,楼上都已经说了,搞个超连接,可以用Hyperlink

#8


有时候用超链不会下载,会直接用IE打开的

建议还是编写下载代码,网上N多,最方便的就是用webclient

#9


引用 4 楼 jiang_jiajia10 的回复:
C# codeprivatevoidFileDownload(stringFullFileName)
  {
   FileInfo DownloadFile=newFileInfo(FullFileName);
   Response.Clear();
   Response.ClearHeaders();
   Response.Buffer=false;
   Response.ContentType="application/octet-stream";
   Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
            Response.…

#10


引用 4 楼 jiang_jiajia10 的回复:
C# code
private void FileDownload(string FullFileName)
  {
   FileInfo DownloadFile = new FileInfo(FullFileName);
   Response.Clear();
   Response.ClearHeaders();
   Response.Buffer = false;
   Response.ContentType ="application/octet-stream";
   Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
  …


用这个OK了、、、

#1


用超级链接不就可以了吗

#2


用超级链接怎么做,我用了不行

#3


<a href="文件全路径">下载</a>

#4



private void FileDownload(string FullFileName)
  {
   FileInfo DownloadFile = new FileInfo(FullFileName);
   Response.Clear();
   Response.ClearHeaders();
   Response.Buffer = false;
   Response.ContentType ="application/octet-stream";
   Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
            Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
   Response.WriteFile(DownloadFile.FullName);
   Response.Flush();
   Response.End();
  } 

#5



<a href="http://www.wowchina.com/download/client/index.shtml?2030" target="_blank">2.2.3到2.3.0升级补丁</a>

#6


弄个超级链接,那要怎么把数据库中的路径绑定到这个超级链接,NavigateUrl要设成什么

#7


顶,楼上都已经说了,搞个超连接,可以用Hyperlink

#8


有时候用超链不会下载,会直接用IE打开的

建议还是编写下载代码,网上N多,最方便的就是用webclient

#9


引用 4 楼 jiang_jiajia10 的回复:
C# codeprivatevoidFileDownload(stringFullFileName)
  {
   FileInfo DownloadFile=newFileInfo(FullFileName);
   Response.Clear();
   Response.ClearHeaders();
   Response.Buffer=false;
   Response.ContentType="application/octet-stream";
   Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
            Response.…

#10


引用 4 楼 jiang_jiajia10 的回复:
C# code
private void FileDownload(string FullFileName)
  {
   FileInfo DownloadFile = new FileInfo(FullFileName);
   Response.Clear();
   Response.ClearHeaders();
   Response.Buffer = false;
   Response.ContentType ="application/octet-stream";
   Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
  …


用这个OK了、、、