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)
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
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

New Topic/Question
Reply



MultiQuote



|