Display executable files in directory VB.Net Exercise - Visual Basic Programming Course


 Exercise

Display executable files in directory

Objetive

Create a program that shows the names (excluding the path) of all executable files (.com, .exe, .bat, .cmd) in the current folder.

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


Juan A. Ripoll - Systems Tutorials and Programming Courses © 2024 All rights reserved.  Legal Conditions.