This website completely moved to new platform. For latest content, visit www.programmingposts.com

Search this Site

7 Sept 2013

VB.NET Program to get Files Full Path in a given Folder

Imports System.IO

Module Module1

    Sub Main()
        Try
            Dim FolderPath As String
            Dim Files As String() 'string array
            Console.WriteLine("www.ProgrammingPosts.blogspot.com")
            Console.WriteLine(vbLf & ">>>VB.NET PROGRAM To PRINT FULL FILES PATH IN A Given Directory  <<<")
            Console.WriteLine(vbLf & "Enter the Directory Path to get File Names in it : ")
            FolderPath = Console.ReadLine()
            Files = Directory.GetFiles(FolderPath)
            Console.WriteLine(vbLf & " The FilePaths in given Directory are : " & vbLf & vbLf)
            For Each FileName As String In Files
                Console.WriteLine(FileName)
            Next
            Console.ReadLine()
        Catch ex As DirectoryNotFoundException 'catching directory not found exception
            Console.BackgroundColor = ConsoleColor.Red
            Console.WriteLine(vbLf & vbLf & " Directory Not Found..Press any key to exit...")
            Console.ReadKey()
        Catch ex As Exception 'catching all other exceptions
            Console.BackgroundColor = ConsoleColor.Red
            Console.WriteLine(vbLf & vbLf & ex.Message)
            Console.ReadKey()
        End Try
    End Sub

End Module
.................
Sample Output : 


No comments:

Post a Comment

Thanks for your comments.
-Sameer