title: how to get the accessible folder names from a drive with vb.net (Visual Studio 2012 Express)
body: <p>I am trying to create a program for a friend that allows him to &quot;sort out&quot; and locate his files.<br />
  He has a couple of drives and many folders.  What I would like to do for him is:</p>
  <ol>
  <li><p>Have code that lists all of the active drives in a combo box. He can then select which drive he wants to search for any or just selected file types by extension.</p>
  </li>
  <li><p>Then he either selects &quot;Everything&quot; or a specific type (ie: Music)</p>
  </li>
  <li><p>Once a button is clicked, a list box fills with the full path to the file</p>
  </li>
  </ol>
  <p>Beginning this writing process, I have accomplished this:</p>
  <pre><code>Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Button1.Enabled = False
  
      Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
  
      Dim d As DriveInfo
      For Each d In allDrives
          If d.IsReady Then ComboBox1.Items.Add(d)
      Next
  
  End Sub
  
  Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
  
      If ComboBox1.SelectedIndex &lt;&gt; -1 Then
  
          Try
  
              For Each DName As String In My.Computer.FileSystem.GetDirectories(ComboBox1.Text, FileIO.SearchOption.SearchTopLevelOnly)
                  Dim LDN As Integer = Len(DName)
                  Dim FName As String = Strings.Mid(DName, 4, LDN - 3)
                  CheckedListBox1.Items.Add(FName, False)
              Next
  
          Catch ex As Exception
  
          End Try
  
      Else
          Exit Sub
      End If
  
  End Sub
  </code></pre>
  <p>My first problem is that the GetDirectories process is getting directories I know that I do not have access to.  I am trying to figure out how to prevent this.  Can anyone help me.</p>