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] ** Directory listing 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 triggerd after connection with server is established. Private Sub wodSFTP1_Connected(ByVal ErrorCode As Integer, ByVal ErrorText As String) If ErrorCode = 0 Then 'We can now request some remote folder for listing. wodSFTP1.ListAttributes "/home/somefolder" Else 'Receive connection error here. If there were any. MsgBox "Connected Error: " & ErrorText End If End Sub 'ListAttributes Method triggered AttributesData Event. 'We will parse directory attributes inside AttributesData Event. Private Sub wodSFTP1_AttributesData(ByVal Items As wodSFTPCOMLib.ISftpItems) Dim item As SftpItem Dim a As String For Each item In Items Debug.Print "Name: " & item.Name If item.Permissions And 16384 Then Debug.Print "Type: Directory" Else Debug.Print "Type: File" Debug.Print "Size: " & item.SizeLo End If Debug.Print " " Next 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 triggerd 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 'We can now request some remote folder for listing. wodSFTP1.ListAttributes("/home/somefolder") Else 'Receive connection error here. If there were any. MsgBox("Connected Error: " + Args.Error.Message) End If End Sub 'ListAttributes Method triggered AttributesData Event. 'We will parse directory attributes inside AttributesData Event. Private Sub wodSFTP1_AttributesDataEvent(ByVal Sender As Object, ByVal Args() As WeOnlyDo.Client.SFTP.AttributesArgs) Handles wodSFTP1.AttributesDataEvent Dim i As Integer For i = Args.GetLowerBound(i) To Args.GetUpperBound(i) Console.WriteLine("Name: " & Args(i).Name) If Args(i).Permissions = "16877" Then Console.WriteLine("Type: Directory") Else Console.WriteLine("Type: File") Console.WriteLine("Size: " & Args(i).Size) End If Console.WriteLine(" ") Next 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.AttributesDataEvent += new WeOnlyDo.Client.SFTP.AttributesDataDelegate(wodSFTP1_AttributesDataEvent); //Authenticate with server using hostname, login, password. wodSFTP1.Hostname = "your_hostname"; wodSFTP1.Login = "your_login"; wodSFTP1.Password = "your_password"; wodSFTP1.Connect(); } //Connected Event is triggerd after connection with server is established. void wodSFTP1_ConnectedEvent(object Sender, WeOnlyDo.Client.SFTP.ConnectedArgs Args) { if (Args.Error == null) { //We can now request some remote folder for listing. wodSFTP1.ListAttributes("/home/somefolder/"); } else //Receive connection error here. If there were any. MessageBox.Show("Connected Error: " + Args.Error.Message); } //ListAttributes Method triggered AttributesData Event. //We will parse directory attributes inside AttributesData Event. void wodSFTP1_AttributesDataEvent(object Sender, WeOnlyDo.Client.SFTP.AttributesArgs[] Args) { int i = 0; int lowerB = Args.GetLowerBound(i); int upperB = Args.GetUpperBound(i); for (i = lowerB; i <= upperB; i++) { Console.WriteLine("Name: " + Args[i].Name); if (Args[i].Permissions == long.Parse("16877")) { Console.WriteLine("Type: Directory"); } else { Console.WriteLine("Type: File"); Console.WriteLine("Size: " + Args[i].Size); } Console.WriteLine(" "); } } |