Hello. I am having a problem. I am attempting to gather a group of file names from a directory. I am able to do this. I tested the code by having the list populate into a listbox and all desired items were added to the list.
Here is my code:

Dim di As New IO.DirectoryInfo(strPath)
        Dim dir1 As IO.FileInfo() = di.GetFiles("*.txt")
        Dim dFiles As IO.FileInfo
       ListBox.Items.Add(dFiles)

However, a listbox is not my desired output. I am attempting to write these file names to a text file for purposes of then parsing the information to a datatable to compare with another datatable.
If anyone knows how to get my filenames written to a a textfile I would appreciate it.

Thanks,

Recommended Answers

All 2 Replies

Dim strPath As String = "C:\Users\GeekByChoiCe\Desktop\"
IO.File.WriteAllLines("C:\Users\GeekByChoiCe\Desktop\test.txt", IO.Directory.GetFiles(strPath, "*.txt"))
commented: Great Help. +1

Worked like a charm. Many thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.