Here's skeleton code that will visit every accessible file on every hard drive on the current system:vb.net Code:
Private Sub SearchComputer() For Each drive As IO.DriveInfo In IO.DriveInfo.GetDrives() If drive.DriveType = IO.DriveType.Fixed Then SearchFolder(drive.Name) End If Next drive End Sub Private Sub SearchFolder(ByVal folder As String) Try For Each subfolder As String In IO.Directory.GetDirectories(folder) SearchFolder(subfolder) Next subfolder For Each file As String In IO.Directory.GetFiles(folder) 'Do whatever is appropriate here with the file path. Console.WriteLine(file) Next file Catch ex As UnauthorizedAccessException 'Ignore this folder as the user does not have permission to access it. End Try End Sub




Reply With Quote