nineclicks
Member
- Joined
- Jun 13, 2013
- Messages
- 18
- Programming Experience
- Beginner
VB.NET:
For Each str As String In Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories)
Dim fi As FileInfo = New FileInfo(str)
If fi.Extension = ".ini" Then
Else
fileList.Add(str)
End If
Next
I'm trying to get all of the files in a directory including sub-directories. Where I am filtering out .ini files I plan to implement a selectable blacklist or whitelist. Anyway the SearchOption.AllDirectories option gives me access denied errors on directories that I don't have access to of course. I simply want to ignore these inaccessible folders, but I don't know how without canceling the entire For loop. Is there a way around this without manually pulling all of the files?
Thanks.