AsyncFtpClient ftp = new AsyncFtpClient();
IAsyncResult result = ftp.BeginConnect( "ftp.server.com", null, null );
while( !result.IsCompleted )
Application.DoEvents();
ftp.EndConnect( result );
result = ftp.BeginLogin( null, null );
while( !result.IsCompleted )
Application.DoEvents();
ftp.EndLogin( result );
result = ftp.BeginGetUploadStream( "test.txt", true, null, null );
while( !result.IsCompleted )
Application.DoEvents();
using( System.IO.Stream stream = ftp.EndGetUploadStream( result ) )
{
byte[] buffer = System.Text.Encoding.ASCII.GetBytes( "Text written to Ftp in a stream" );
stream.Write( buffer, 0, buffer.Length );
}
return;