2008-10-01, 16:18
stargazer Wrote:I am getting the same error as I have a drive dedicated to movies where each movie is in a folder on the root of the disk. I do not have a VB background, but the code snippet is pretty easy to follow. You can try substituting a for..to loop in place of the for each loop. Then you can have an exception handler around the body of the for..to loop an skip the offending directory. This assumes that the GetDirectories call is succeeding, but accessing entries in will not.
Unfortunatley the code you provided doesn't work, I think i've found a solution though.
Code:
tempint = realpathcount + 1
For f = 1 To realpathcount
'tempstring = realpaths(f)
For Each strfolder As String In My.Computer.FileSystem.GetDirectories(realpaths(f))
Try
If strfolder.IndexOf("System Volume Information") = -1 Then
realpathcount += 1
realpaths(realpathcount) = strfolder
End If
Catch ex As Exception
MsgBox("error")
End Try
Next
Next
'add an additional loop for the recursive scan
For g = tempint To realpathcount
For Each strfolder As String In My.Computer.FileSystem.GetDirectories(realpaths(g), FileIO.SearchOption.SearchAllSubDirectories)
Try
If strfolder.IndexOf("System Volume Information") = -1 Then
realpathcount += 1
realpaths(realpathcount) = strfolder
End If
Catch ex As Exception
MsgBox("error")
End Try
Next
Next
There should be no problem though for people who use a drive for nothing but media or for those few who store media on the root of a drive.