I have a folder ("EDI") [editions] with .txt files inside (01,02,03,04) I have this functional code:
ListBox2.Items.AddRange(File.ReadAllLines(Application.StartupPath & "\Cat\EDI\", "01.txt"))
ListBox2.Items.AddRange(File.ReadAllLines(Application.StartupPath & "\Cat\EDI\", "02.txt"))
ListBox2.Items.AddRange(File.ReadAllLines(Application.StartupPath & "\Cat\EDI\", "03.txt"))
until 68. Each file contains a list songs. But if I try to reduce the code implementing at "For Loop", as:
For i = 1 To 70
ListBox2.Items.AddRange(File.ReadAllLines(Application.StartupPath & "\Cat\EDI\", (i) & ".txt"))
Next
I get an error at (i) & ".txt"
. Says: "String cannot be converted in coding"
How can i solve?. Some to take in care is the name of the text files are 01.txt,02.txt WITH 2 NUMBERS, also the "for-loop" automatically changes 01 into 1
or better... How can i load all the text lines of all existent text files at folder?
I already have the list of files if it needed, I use this code to get all txt file names into another ListBox:
Dim newroot As String
newroot = (Application.StartupPath & "\Cat\EDI\")
listbox1.items.AddRange(IO.Directory.GetFiles(newroot, "*.txt").
Select(Function(f) IO.Path.GetFileNameWithoutExtension(f)))