Asynchronous-File-Download-with-progress-monitoring - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Asynchronous File Download with progress monitoring
Set Protocol property to change the protocol in below code
VB code
Dim WithEvents wodFtpDLX As wodFtpDLXCom
Private Sub Form_Load()
    Set wodFtpDLX = New wodFtpDLXCom

    ' Set connection parameters
    wodFtpDLX.HostName = "xx"
    wodFtpDLX.Login = "xx"
    wodFtpDLX.Password = "xx"
    wodFtpDLX.Protocol = FTP

    ' Initiate the connection
    wodFtpDLX.Connect
End Sub

' Connected event is triggered when Connection is successful/or fails. If connection failed
' ErrorCode will be <> 0, and in that case, ErrorText will contain description of an error
' which occured.
Private Sub wodFtpDLX_Connected(ByVal ErrorCode As Long, ByVal ErrorText As String)
    If ErrorCode = 0 Then
        wodFtpDLX.GetFile "C:\", "/home/remote_filename"
    End If
End Sub

' When method finishes execution, Done event is triggered. This is where we will disconnect.
Private Sub wodFtpDLX_Done(ByVal ErrorCode As Long, ByVal ErrorText As String)
    wodFtpDLX.Disconnect
End Sub

Private Sub wodFtpDLX_Progress(ByVal Position As Long, ByVal Total As Long)
    Debug.Print Position & " / " & Total
End Sub
C# code
private WeOnlyDo.Client.FtpDLX wodFtpDLX;
private void Form1_Load(object sender, EventArgs e)
{
    wodFtpDLX = new WeOnlyDo.Client.FtpDLX();
    // Declare events
    wodFtpDLX.ConnectedEvent +=new WeOnlyDo.Client.FtpDLX.ConnectedDelegate(wodFtpDLX_ConnectedEvent);
    wodFtpDLX.DoneEvent +=new WeOnlyDo.Client.FtpDLX.DoneDelegate(wodFtpDLX_DoneEvent);
    wodFtpDLX.ProgressEvent +=new WeOnlyDo.Client.FtpDLX.ProgressDelegate(wodFtpDLX_ProgressEvent);

    // Set connection parameters
    wodFtpDLX.Hostname = "xx";
    wodFtpDLX.Login = "xx";
    wodFtpDLX.Password = "xx";
    wodFtpDLX.Protocol = WeOnlyDo.Client.Protocols.FTP;

    // Initiate the connection
    wodFtpDLX.Connect();
}

// When method finishes execution, Done event is triggered. This is where we will disconnect.
void wodFtpDLX_DoneEvent(object Sender, WeOnlyDo.Client.FtpDoneArgs Args)
{
    wodFtpDLX.Disconnect();
}

// Connected event is triggered when Connection is successful/or fails. If connection failed
// Args parameter will contain exception of an error
void wodFtpDLX_ConnectedEvent(object Sender, WeOnlyDo.Client.FtpConnectedArgs Args)
{
    wodFtpDLX.GetFile("C:\\", "/home/remote_filename");
}

// Progress event will will be triggered multiple times, providing you with amount of data
// transferred so far, as well as size of the file being uploaded.
void wodFtpDLX_ProgressEvent(object Sender, WeOnlyDo.Client.FtpProgressArgs Args)
{
    Console.WriteLine(Args.Position + " / " + Args.Total);
}
VB.NET code
Dim WithEvents wodFtpDLX As WeOnlyDo.Client.FtpDLX
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    wodFtpDLX = New WeOnlyDo.Client.FtpDLX
   
    ' Set connection parameters
    wodFtpDLX.Hostname = "xx"
    wodFtpDLX.Login = "xx"
    wodFtpDLX.Password = "xx"
    wodFtpDLX.Protocol = WeOnlyDo.Client.Protocols.FTP
    
    ' Initiate the connection
    wodFtpDLX.Connect()
End Sub

' Connected event is triggered when Connection is successful/or fails. If connection failed
' Args parameter will contain exception of an error
Private Sub wodFtpDLX_ConnectedEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Client.FtpConnectedArgs) Handles wodFtpDLX.ConnectedEvent
    wodFtpDLX.GetFile("C:\\", "/home/remote_filename")
End Sub

'When method finishes execution, Done event is triggered. This is where we will disconnect.
Private Sub wodFtpDLX_DoneEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Client.FtpDoneArgs) Handles wodFtpDLX.DoneEvent
    wodFtpDLX.Disconnect()
End Sub

' Progress event will will be triggered multiple times, providing you with amount of data
' transferred so far, as well as size of the file being uploaded.
Private Sub wodFtpDLX_ProgressEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Client.FtpProgressArgs) Handles wodFtpDLX.ProgressEvent
    Debug.Print(Args.Position & " / " & Args.Total)
End Sub