title: Ignore unaccessable Files at DirectoryInfo.GetFiles
body: <p>So, I am trying to make a File-Search-Program, which should also search through all sub-folders of the given folder. The problem is, that if I want to search on <code>C:\</code> for example, I get an <code>UnauthorizedAccessException</code>. I know that I could make a "Try"-Statement, but that doesn't work either because then the FileInfo stays Nothing.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>Sub SubfolderSearch()
  
      Dim diar2 As IO.FileInfo()
      Dim di2 As New IO.DirectoryInfo(Path)
  
      diar2 = di2.GetFiles("*", IO.SearchOption.AllDirectories) 'The Error occurs in this line
  
      Dim dra As IO.FileInfo
  
          For Each dra In diar2
  
              Dim FileName As String = dra.Name
              Dim FilePath As String = dra.FullName
              Dim FileSize As Integer = dra.Length / 1000
  
              'Search Procedure'
  
          Next
  
          SubfolderThread.Abort()
  </code></pre>