I'm trying to write a search routine that will search the hard drive for a list of files to see if they exist, I keep getting this error:

An unhandled exception of type 'System.ArgumentException' occurred in search.exe

Additional information: The parameter is incorrect.

it crashes on this line:

oFolder = oFS.GetFolder(oFolders(FolderKey.Current).Path.ToString)


it also crashes on the msgbox line that is commented out, and I just don't see why.

Public Function File_Search_Test( ByVal rs As ADODB.Recordset) As String

Dim oFS As New Scripting.FileSystemObject()
Dim oFolder As Scripting.Folder
Dim oFolders As Scripting.Folders
Dim oDrives As Scripting.Drives
Dim oDrive As Scripting.Drive
Dim iCount As Short
Dim iFolder As Short
Dim oKey As IEnumerator
Dim FolderKey As IEnumerator

oDrives = oFS.Drives

oKey = oDrives.GetEnumerator

Do Until oKey.MoveNext = False

If oDrives(oKey.Current).DriveType.ToString = "Fixed" Then
oFolders = oDrives(oKey.Current).RootFolder.SubFolders
FolderKey = oFolders.GetEnumerator
FolderKey.MoveNext()
'MsgBox(oFolders.Item(FolderKey.Current).Name.ToString)
oFolder = oFS.GetFolder(oFolders(FolderKey.Current).Path.ToString)
MsgBox(oFolder.Name)

End If