DirectoryInfo.GetFiles returns a file list from the current directory matching the given search pattern.
Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
Try
Dim di As DirectoryInfo = New DirectoryInfo("c:\")
Dim dirs As DirectoryInfo() = di.GetDirectories("*p*")
Console.WriteLine("Number of directories with a p: {0}", dirs.Length)
Dim diNext As DirectoryInfo
For Each diNext In dirs
Console.WriteLine("The number of files in {0} with an e is {1}",diNext, diNext.GetFiles("*e*").Length)
Next
Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
End Sub
End Class
Related examples in the same category