Click here to Skip to main content
12,557,291 members (28,910 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB 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
please help me
Posted 4-Jan-13 16:18pm
Updated 4-Jan-13 17:42pm
Sandeep Mewara 4-Jan-13 23:44pm
Can you elaborate 'not working' and our observations when you debugged it?
Rate this: bad
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
Rate this: bad
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:[^].

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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161026.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100