0

i cant access other special folder, like My Music, please help me, i need to include all the subfolder inside My documents..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchAllSubDirectories, "*.txt")
        ListBox1.Items.Add(foundFile)
    Next
End Sub
Mark Hall
  • 53,938
  • 9
  • 94
  • 111
  • 1
    Use the [`Environment.SpecialFolder.MyMusic`](http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx) value in conjunction with the [`Environment.GetFolderPath` method](http://msdn.microsoft.com/en-us/library/14tx8hby.aspx) to access the "My Music" folder. – Cody Gray - on strike Jan 16 '12 at 05:02
  • thx for the reply. :)when i used that, it will only include the "My Music" folder. how about the other folder? i need to include every folder inside my docs. – Ramon Jorge Pantig Evangelista Jan 16 '12 at 05:13
  • If you look at the link Cody Gray gave you, one of the enumerations for SpecialFolder is MyDocuments (i.e., Environment.SpecialFolder.MyDocuments). – Tim Jan 16 '12 at 07:58

1 Answers1

0

try this

        Dim MyDoc As New IO.FileInfo(My.Computer.FileSystem.SpecialDirectories.MyDocuments)
        For Each foundFile As String In My.Computer.FileSystem.GetFiles(MyDoc.Directory.FullName, FileIO.SearchOption.SearchAllSubDirectories, "*.txt")
            ListBox1.Items.Add(foundFile)
        Next
VJPPaz
  • 917
  • 7
  • 21