VB.NET Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

Asynchronous FTP Upload

Download: Chilkat .NET Assemblies

VB.NET example code showing how to upload in a background thread, monitor the progress, an abort if necessary.

    ' Asynchronous FTP Upload
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

        Dim success As Boolean

        Dim ftp As New Chilkat.Ftp2()

        success = ftp.UnlockComponent("Anything for 30-day trial")
        If (Not success) Then
            MessageBox.Show("Component not unlocked")
            Exit Sub
        End If

        ' Set the FTP hostname, login, and password.
        ftp.Hostname = "ftp.***.com"
        ftp.Username = "***"
        ftp.Password = "***"

        ' Connect and login to the FTP server.
        success = ftp.Connect()
        If (Not success) Then
            MessageBox.Show(ftp.LastErrorText)
            Exit Sub
        End If

        ' Begin the upload in a background thread:
        Dim localFilename As String
        Dim remoteFilename As String
        localFilename = "hamlet.xml"
        remoteFilename = "hamlet.xml"

        success = ftp.AsyncPutFileStart(localFilename, remoteFilename)
        If (Not success) Then
            MessageBox.Show(ftp.LastErrorText)
            Exit Sub
        End If

        ' This is where your application might do other interesting tasks...
        ' This example will loop and update the current upload rate and bytes
        ' transferred.
        While Not ftp.AsyncFinished

            System.Threading.Thread.Sleep(100)

            ' Handle application events so our user interface remains responsive.
            Application.DoEvents()

            ' Update label controls with the current data rate and # bytes downloaded.
            Label1.Text = "Bytes/Second: " & Convert.ToString(ftp.UploadRate)
            Label1.Refresh()

            Label2.Text = "Bytes Received: " & Convert.ToString(ftp.AsyncBytesSent)
            Label2.Refresh()

            ' The upload can be aborted at any time by calling AsyncAbort
            If AbortButtonPressed Then
                ftp.AsyncAbort()
            End If

        End While

        ' The upload is finished, now check the success:
        If Not ftp.AsyncSuccess Then

            MessageBox.Show(ftp.AsyncLog)

        End If

        ' Disconnect
        ftp.Disconnect()

        ' We're finished!
        MessageBox.Show("FTP Async Upload Finished!")

    End Sub

 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser