Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
hello guy am having a little problem:
my goal is to get all file with an mp3 extension listed on a listbox in vb
in that case the location of that directory in c:\Users\%Username%\music
 
I have this code but it's not working:
Dim di As New IO.DirectoryInfo("C:\Users\%userprofile%\Music")
        Dim diar1 As IO.FileInfo() = di.GetFiles()
       Dim dra As IO.FileInfo
       
        For Each dra In diar1
       ListBox1.Items.Add(dra)
       Next
please help me
Posted 4-Jan-13 16:18pm
sean871493
Edited 4-Jan-13 17:42pm
v2
Comments
Sandeep Mewara at 4-Jan-13 23:44pm
   
Can you elaborate 'not working' and our observations when you debugged it?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try the following:
For Each dra In diar1
ListBox1.Items.Add(dra.Name) ' or dra.FullName
Next
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

For such a simple thing, use System.IO.Directory instead. I don't know what to explain here; everything is written: http://msdn.microsoft.com/en-us/library/system.io.directory.aspx[^].
 
Oh no, sorry, not everything. There is one unpleasant subliminal Microsoft problem about it. Please see:
Directory.Get.Files search pattern problem[^].
 
First, I learned about it from CodeProject members! Highly appreciate the lesson.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 375
1 Abhinav S 333
2 OriginalGriff 330
3 sanket saxena 305
4 CPallini 205
0 Sergey Alexandrovich Kryukov 8,497
1 OriginalGriff 4,850
2 Peter Leow 3,839
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid