XceedFtpLib.XceedFtp ftp = new XceedFtpLib.XceedFtpClass(); ftp.License( @"your license key" );
// Specify the FTP server's address ftp.ServerAddress = @"ftp.cdrom.com";
// Specify the username and password to login ftp.UserName = "anonymous"; ftp.Password = "guest";
try { // Connect to the FTP server ftp.Connect();
// Subscribe to the ReceivingMemoryFileData event in order // to process the data being received. ftp.ReceivingMemoryFileData += new XceedFtpLib.DXceedFtpEvents_ReceivingMemoryFileDataEventHandler( this.ftp_ReceivingMemoryFileData );
// Start receiving a file to memory ftp.ReceiveMemoryFile( "test.txt", 0, XceedFtpLib.EXFReceiveMemoryOptions.fmoSingleBlock );
// In the line above, we chose to receive the data in a single // block of data. So the ReceivingMemoryFile event will only // be triggered once. You can change the value of the third // parameter to receive the data in many smaller chunks, // whenever data is received by the Xceed FTP Library.
// Disconnect from the FTP server ftp.Disconnect(); } catch( System.Runtime.InteropServices.COMException except ) { MessageBox.Show( except.ToString() ); }
private void ftp_ReceivingMemoryFileData( string remoteFilename, int fileSize, ref object data, bool endOfData ) { listBox1.Items.Add( System.Text.Encoding.Default.GetString( ( byte[] )data ) ); }
|