How To Enumerate Files Using VB.NET

In this article I describe how to enumerate a files in VB.Net
  • 3731

Enumerate Files in VB.NET

The Directory.EnumerateFiles method returns an enumerable collection of file names in the specified directory.

Imports System.IO

Module Module1

    Sub Main()

        Dim root As String = "C:\Temp"

        ' Get a list of all subdirectories

        Dim files = From file In Directory.EnumerateFiles(root)

        Console.WriteLine("Files: {0}", files.Count().ToString())

        Console.WriteLine("List of Files")

        For Each file In files

            Console.WriteLine("{0}", file)

        Next

        Console.ReadLine()

    End Sub

End Module

Output:

Enumerate files in vb.jpg

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.