Webclient下载数据 [英] Webclient download data

查看:73
本文介绍了Webclient下载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想从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();

推荐答案

Seema Gosain写道:
Seema Gosain wrote:

如果我下载700mb 500mb之类的大文件,则无法打开.

If I download large files like 700mb 500mb then it not opening.


您是否在Web.Config文件中使用适当的值设置了HttpRuntime元素?对于如此大的文件,这将花费更多时间,因此您需要在此之前保持请求/响应有效,并增加请求的大小.

阅读:
httpRuntime元素(ASP.NET设置架构) [


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下载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆