Display executable files in directory Learn programming Visual Basic (VB.net)

Lesson:

Additional Libraries


Exercise:

Display executable files in directory 32


Objetive:

Create a program to display the name (but not the path) of the executable files (.com, .exe, .bat, .cmd) in the current directory


Code:

Imports System
Imports System.IO
Class DisplayExecutableFiles
    Private Shared Sub Main()
        Dim files As String() = Directory.GetFiles(".")

        For Each file As String In files
            Dim extension As String = Path.GetExtension(file)

            Select Case extension
                Case ".exe", ".com", ".bat", ".cmd"
                    Console.WriteLine(file)
            End Select
        Next
    End Sub
End Class