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

 

 

 

 

 

 

Get Number of FIles in Directory, not including sub-directories

VB.NET example demonstrating how to get the number of files in a directory not including sub-directories.

Download: Chilkat .NET Assemblies

Dim ftp As New Chilkat.Ftp2()

Dim success As Boolean

'  Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


ftp.Hostname = "www.myFtpServer.com"
ftp.Username = "****"
ftp.Password = "****"

'  Connect and login to the FTP server.
success = ftp.Connect()
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


'  The ListPattern property is our directory listing filter.
'  The default value is "*", which includes everything.
TextBox1.Text = TextBox1.Text & ftp.ListPattern & vbCrLf

'  Fetch the current remote directory contents by
'  accessing the NumFilesAndDirs property.
Dim i As Long
Dim n As Long
n = ftp.NumFilesAndDirs
If (n < 0) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If

If (n > 0) Then
    '  Loop over the directory contents, incrementing the count
    '  each time it is NOT a directory.
    Dim fileCount As Long
    fileCount = 0
    For i = 0 To n - 1

        '  Is this NOT a sub-directory?
        If (ftp.GetIsDirectory(i) <> true) Then
            fileCount = fileCount + 1
            '  Display the filename
            TextBox1.Text = TextBox1.Text & ftp.GetFilename(i) & vbCrLf
        End If


    Next

    TextBox1.Text = TextBox1.Text & "Total number of files = " _
         & fileCount & vbCrLf
End If



ftp.Disconnect()
 

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

Mail Component · XML Parser