How To Enumerate Files Using VB.NET

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

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)



    End Sub

End Module


Enumerate files in vb.jpg


More Articles

© 2020 DotNetHeaven. All rights reserved.