Hey, i've got a small search app that allows the user to specify a location to search on their local machine, if none is specified the app searches through all drives and folders on that machine. The problem is,i've got a folder that is locked.I was moving it and cancelled it half way or the power went off or something, i can't remember, bottom line is every time i try access it i get the "Access denied" message. I've tried renaming it(only managed to rename it once), booting in safe mode(Running XP), command prompt, third party software to force unlock it, scheduling it for deletion up startup, but nothing works. And now everytime i search through that drive i get an error. It's not serious and seeing as how i know the folder name i can exclude it from the search, but it is FREAKING annoying. And it just highlights the fact that it may occur on another machine where i don't know about it before execution.
So my question is, is there a way to test for folders/files that are denied and then exclude them from a search
this is part of the code i'm using, don't think i need to post it (remember absolute noob)
CODE
For Each d In allDrives
Dim drivename As String = d.Name
If d.DriveType.ToString = "Fixed" Then
Dim errorfolder As String = drivename + "System Volume Information"
If String.Equals(searchFolderName, "") Then 'checks to see user has not specified folder
'List each folder at the root of specified drive
For Each strFolder As String In My.Computer.FileSystem.GetDirectories(drivename)
'Add the item to the list
lstData.Items.Add(strFolder)
If strFolder <> errorfolder Or strFolder <> "f:\g" Then
Me.SearchForFiles(strFolder, FileIO.SearchOption.SearchAllSubDirectories, filename)
End If
Next
Else
If searchFolderName <> errorfolder Or searchFolderName <> "f:\g" Then
searchFolderName = drivename + searchFolderName
Me.SearchForFiles(searchFolderName, FileIO.SearchOption.SearchAllSubDirectories, filename)
End If
End If
End If
Next
not sure if i need to include this part but just in case
CODE
Protected Sub SearchForFiles(ByVal directory As String, ByVal searchOption As Microsoft.VisualBasic.FileIO.SearchOption, ByVal wildCards As String)
wildCards = "1.1"
Try
For Each foundFile As String In My.Computer.FileSystem.GetFiles(directory, searchOption, wildCards)
lstBooks.Items.Add(foundFile)
tempCount = tempCount + 1
Next
Catch ex As Exception
MessageBox.Show("Exception thrown: " & ex.Message)
End Try
End Sub