VB.NET Program to get Files Full Path in a given Folder
In this post we will see a VB.Net Program to retrieve list of file names with full path in a given folder/directory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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 :