0

I want to read out file names but the file names are not in the listbox, for example I have a file with 3 text files in there and I want to see the text files name in the listbox. At the web i found this code but it read not the file names

For Each Filename In FileIO.FileSystem.GetFileInfo("C:\Windows\Fonts\").Name
        listbox1.Items.Add(Filename)
    Next
        
Bastitron
  • 23
  • 4
  • 1
    Does this answer your question? [Get a list of all files inside of a directory in vb.net](https://stackoverflow.com/questions/1457525/get-a-list-of-all-files-inside-of-a-directory-in-vb-net) – MatSnow Jul 07 '20 at 10:08
  • Your code just returns the name of the last folder in the path `C:\Windows\Fonts` and adds each character of it to the listbox. – MatSnow Jul 07 '20 at 10:10

1 Answers1

0

Try This

Dim FolderInfo = New DirectoryInfo("C:\Windows\Fonts\")
For Each File In FolderInfo.GetFiles
    ListBox1.Items.Add(File)
Next
Bharath
  • 72
  • 11