|
-
September 11th, 2009, 06:24 AM
#1
FtpWebRequest - downloading big files
Hello,
I'm using FtpWebRequest to download files from FTP server.
For small files <= 20MB everything is going well, but if the file is 100-200MB, it fails..
it downloads like 50-70MB and then application hangs... after some time it shows popup window with this information:
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
the setting sor FtpWebRequest look like this:
Code:
partRequest = FtpWebRequest.Create(ftpUrl) as FtpWebRequest;
partRequest.Method = WebRequestMethods.Ftp.DownloadFile;
partRequest.Credentials = new NetworkCredential(FtpUsername, FtpPassword);
partRequest.UsePassive = true;
partRequest.UseBinary = true;
partRequest.KeepAlive = false; // close the connection when done
partRequest.Timeout = Int32.MaxValue; //this line didn't help :(
FtpWebResponse partResponse = partRequest.GetResponse() as FtpWebResponse;
Stream partReader = partResponse.GetResponseStream();
byte[] buffer = new byte[1024];
FileInfo fi = new FileInfo(path);
FileStream memStream = fi.Create();
while (true)
{
Application.DoEvents();
// Try to read the data
int bytesRead = partReader.Read(buffer, 0, buffer.Length);
if (bytesRead == 0)
break;
memStream.Write(buffer, 0, bytesRead);
}
Do you have any suggestions? What can be a reason why it crashes with bigger files..
Maybe you know some library which is tested and works with large files (~2GB)
Hope somebody know the solution.. i spent 2 days on looking for it in the internet with no result.
Cheers
Ka-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|