Xceed FTP Library Documentation
Example topics / Receiving a file to memory (VB.NET example)
In This Topic
    Receiving a file to memory (VB.NET example)
    In This Topic
    VB.NET Copy Code

    Dim ftp As 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.
       AddHandler ftp.ReceivingMemoryFileData, AddressOf Me.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 except As System.Runtime.InteropServices.COMException
       MessageBox.Show( except.ToString() )
    End Try

    Private Sub ftp_ReceivingMemoryFileData( ByVal remoteFilename As String, ByVal fileSize As Integer, ByRef data As Object, ByVal endOfData As Boolean )
       listBox1.Items.Add( System.Text.Encoding.Default.GetString( CType( data, Byte() ) ) )
    End Sub