Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Get File and Directory InformationDownload: Chilkat .NET Assemblies Demonstrates how to get information about the files and directories in the current remote directory on an FTP server. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
ftp2.UnlockComponent("Anything for 30-day trial")
ftp2.Hostname = "ftp.chilkatsoft.com"
ftp2.Username = "***"
ftp2.Password = "***"
' Connect to the FTP server and login.
Dim success As Boolean
success = ftp2.Connect()
If (Not success) Then
ftp2.SaveLastError("ftpError.txt")
Exit Sub
End If
' Setting the ListPattern property causes a directory listing command to be sent to the FTP server.
' The Ftp2 object's properties (such as NumFilesAndDirs) and methods are automatically updated
' to reflect the new ListPattern.
ftp2.ListPattern = "*"
Dim i As Integer
Dim n As Integer
Dim fname As String
Dim fileSize As Integer
Dim lastMod As Date
Dim isDir As Boolean
n = ftp2.NumFilesAndDirs
For i = 0 To n - 1
fname = ftp2.GetFilename(i)
fileSize = ftp2.GetSize(i)
lastMod = ftp2.GetLastModifiedTime(i)
isDir = ftp2.GetIsDirectory(i)
ListBox1.Items.Add(fname + ", " + Convert.ToString(fileSize) + ", " + _
Convert.ToString(lastMod) + ", " + Convert.ToString(isDir))
Next
ftp2.Disconnect()
MessageBox.Show("Finished!")
End Sub
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.