I am currently trying to download a large file (1.13gb) from a ftp location and it is timing out.
When I checked the download was only doing about 350mb every 10 mins on the server. Other than increasing the request.Timeout to almost an hour (!!) is there a better way to download and stream large files like this.
Here is the code I am currently using:
private void DownloadFromFtp(IFeedProviderConfiguration configuration, string urlData)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(urlData);
if (!string.IsNullOrEmpty(configuration.Username))
{
request.Credentials = new NetworkCredential(configuration.Username, configuration.Password);
}
request.ReadWriteTimeout = 600000;
request.Timeout = 600000;
request.UseBinary = true;
request.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
var stream = GetUnCompressFromStream(urlData, response.GetResponseStream());
/*StreamReader reader = new StreamReader(responseStream);
documentContent = reader.ReadToEnd();
reader.Close();*/
this.WriteToFile(stream, this._localFile);
stream.Close();
}