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



Lesson:

Additional Libraries


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 ©  All rights reserved.  Legal Conditions.