how to save ListBox in vb.net
Dim files() As String
files = Directory.GetFiles("C:\", "*.mp3")
Dim file As String
For Each file In files
ListBox1.Items.Add(Path.GetFileName(file))
Next
output :
00001.mp3
00003.mp3
00005.mp3 ....
want to save all item wth Only filenam to another folder.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
'You can do it like this:
'I prefer to use ArrayList instad of simple arrays because they are more flexible and you can inherit one arraylist inside another...
How exactly do you want to save the list? Just as a list in a text file? There are a bunch of ways.
Personally I'd probably use a List(Of String) instead of an array of string. It makes the For loop easier, but you have to convert the list to an array to WriteAllLines. Still, I like Lists...
But the first option is likely the best option, since you don't have to convert to a list and then back to an array. It's unnecessary overhead.
You can also use File.WriteAllText() to write a string to the file.
Note that you could also write this out using many other methods, including StreamWriter