Mega Code Archive
Count the files in a directory
Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
Dim path As String = "c:\MyDir"
Dim target As String = "c:\TestDir"
Try
'Create a file in the directory.
File.CreateText(target + "\myfile.txt")
Console.WriteLine("The number of files in {0} is {1}", _
target, Directory.GetFiles(target).Length)
Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
End Sub
End Class