Aborting-File-Transfer-using-SFTP-protocol - 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] **

Aborting file transfer using SFTP protocol
VB code
Dim WithEvents wodSFTP1 As wodSFTPCom
Private Sub Form_Load()
    Set wodSFTP1 = New wodSFTPCom
    
    'Authenticate with server using hostname, login, password.
    wodSFTP1.HostName = "your_hostname"
    wodSFTP1.Login = "your_login"
    wodSFTP1.Password = "your_password"
    wodSFTP1.Connect
End Sub

'Connected Event is triggered after connection with server is established.
Private Sub wodSFTP1_Connected(ByVal ErrorCode As Integer, ByVal ErrorText As String)
    If ErrorCode = 0 Then
       'In this example we will upload some file to server. Same procedure is for downloading file.
'When downloading file GetFile Method should be used.
wodSFTP1.PutFile "c:\somefile.exe", "/home/somefolder" Else 'Receive connection error here. If there were any. MsgBox "Connected Error: " & ErrorText End If End Sub Private Sub Command1_Click() 'In any time during file transfer we can abort it using Abort Method. wodSFTP1.Abort End Sub 'Done Event is triggered when some wodSFTP method is finished with execution. Private Sub wodSFTP1_Done(ByVal ErrorCode As Integer, ByVal ErrorText As String) 'Aborting file transfer using Abort Method will produce error. 'That error we can catch inside Done Event using Done Event ErrorText and ErrorCode argument. If ErrorCode <> 0 Then MsgBox "Done Error: " & ErrorText End If End Sub
VB.NET code
Dim WithEvents wodSFTP1 As WeOnlyDo.Client.SFTP
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    wodSFTP1 = New WeOnlyDo.Client.SFTP

    'Authenticate with server using hostname, login, password.
    wodSFTP1.Hostname = "your_hostname"
    wodSFTP1.Login = "your_login"
    wodSFTP1.Password = "your_password"
    wodSFTP1.Connect()
End Sub

'Connected Event is triggered after connection with server is established.
Private Sub wodSFTP1_ConnectedEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Client.SFTP.ConnectedArgs) Handles wodSFTP1.ConnectedEvent
    If (Args.Error Is Nothing) Then
        'In this example we will upload some file to server. Same procedure is for downloading file.
'When downloading file GetFile Method should be used.
wodSFTP1.PutFile("c:\somefile.exe", "/home/somefolder") Else 'Receive connection error here. If there were any. MsgBox("Connected Error: " + Args.Error.Message) End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'In any time during file transfer we can abort it using Abort Method. wodSFTP1.Abort() End Sub 'Done Event is triggered when some wodSFTP.NET method is finished with execution. Private Sub wodSFTP1_DoneEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Client.SFTP.DoneArgs) Handles wodSFTP1.DoneEvent 'Aborting file transfer using Abort Method will produce error. 'That error we can catch inside Done Event using Done Event Error argument. If Args.Error IsNot Nothing Then MsgBox("Done Error: " & Args.Error.Message) End If End Sub
C# code
WeOnlyDo.Client.SFTP wodSFTP1;
private void Form1_Load(object sender, EventArgs e)
{
    wodSFTP1 = new WeOnlyDo.Client.SFTP();
    wodSFTP1.ConnectedEvent += new WeOnlyDo.Client.SFTP.ConnectedDelegate(wodSFTP1_ConnectedEvent);
    wodSFTP1.DoneEvent += new WeOnlyDo.Client.SFTP.DoneDelegate(wodSFTP1_DoneEvent);

    //Authenticate with server using hostname, login, password.
    wodSFTP1.Hostname = "your_hostname";
    wodSFTP1.Login = "your_login";
    wodSFTP1.Password = "your_password";
    wodSFTP1.Connect();
}

//Connected Event is triggered after connection with server is established.
void wodSFTP1_ConnectedEvent(object Sender, WeOnlyDo.Client.SFTP.ConnectedArgs Args)
{
    if (Args.Error == null)
    {
        //In this example we will upload some file to server. Same procedure is for downloading file.
//When downloading file GetFile Method should be used.
wodSFTP1.PutFile("c:\\somefile.exe", "/home/somefolder"); } else //Receive connection error here. If there were any. MessageBox.Show("Connected Error: " + Args.Error.Message); } private void button1_Click(object sender, EventArgs e) { //In any time during file transfer we can abort it using Abort Method. wodSFTP1.Abort(); } //Done Event is triggered when some wodSFTP.NET method is finished with execution. void wodSFTP1_DoneEvent(object Sender, WeOnlyDo.Client.SFTP.DoneArgs Args) { //Aborting file transfer using Abort Method will produce error. //That error we can catch inside Done Event using Done Event Error argument. if (Args.Error != null) { MessageBox.Show("Done Error: " + Args.Error.Message); } }