问题描述
我想从ftp服务器下载数据.现在的问题是,如果我下载小文件eps或cdr,则可以正常工作.如果我下载700mb 500mb之类的大文件,则无法打开.
----代码------
Hi,
I want to download data from the ftp server. Now issue is if I download small files eps or cdr then it work fine. If I download large files like 700mb 500mb then it not opening.
----Code------
Response.AddHeader("content-disposition", "attachment; filename=" + filename + "");
WebClient request = new WebClient();
request.Credentials = new NetworkCredential(username, passwd);
string sSavePath = ftpServer + foldername + filename;
byte[] fileddat = request.DownloadData(sSavePath);
byte[] fileddat = request.DownloadData(sSavePath);
Response.BinaryWrite(fileddat);
Response.End();
推荐答案
如果我下载700mb 500mb之类的大文件,则无法打开.
If I download large files like 700mb 500mb then it not opening.
您是否在Web.Config文件中使用适当的值设置了HttpRuntime元素?对于如此大的文件,这将花费更多时间,因此您需要在此之前保持请求/响应有效,并增加请求的大小.
阅读:
httpRuntime元素(ASP.NET设置架构) [ ^ ]
您需要增加executionTimeout
& maxRequestLength
即使执行完这些操作,如果仍然有错误/问题,请告诉我们它是什么.
Have you set the HttpRuntime element with proper values in Web.Config file? For such big files it will take more time and thus you need to keep the request/response alive till then and also increase the size of request.
Read:
httpRuntime Element (ASP.NET Settings Schema)[^]
You would need to increase executionTimeout
& maxRequestLength
Even after doing these, if there is some error/issue tell us what it is.
这篇关于Webclient下载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!