The following code was tested and did not encounter a timeout
void download_file ( string host,
string path,
string filename,
string user_name,
string password,
string target_path )
{
StringBuilder sb = new StringBuilder ( );
sb.Append ( "ftp://" );
sb.Append ( host );
sb.Append ( "/" );
sb.Append ( path );
sb.Append ( "/" );
sb.Append ( filename );
try
{
FtpWebRequest request;
request = ( FtpWebRequest ) WebRequest.Create (
sb.ToString ( ) );
request.Method = WebRequestMethods.Ftp.DownloadFile;
if ( String.IsNullOrEmpty ( user_name ) )
{
user_name = "anonymous";
}
request.Credentials = new NetworkCredential (
user_name,
password );
using ( FtpWebResponse response =
( FtpWebResponse ) request.
GetResponse ( ) )
{
using ( Stream rs = response.
GetResponseStream ( ) )
{
using ( StreamReader sr =
new StreamReader ( rs ) )
{
File.WriteAllText ( target_path,
sr.ReadToEnd ( ) );
}
}
MessageBox.Show (
String.Format (
"Download Complete {0}status{0}{1}",
Environment.NewLine,
response.StatusDescription ) );
}
}
catch ( Exception ex )
{
MessageBox.Show (
String.Format (
"Download Failed{0}{1}{2}",
Environment.NewLine,
ex.Message,
ex.StackTrace ) );
}
}
The Usings were:
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
Hope that helps.