The most efficient way to search a file
1) There are about 100,000 files in a directory, and I need to know the most efficient way to find a file in that directory.
2) Also, I'm trying to determine if directory A has over 100,000, then create directory B and put files in that directory, so that file search will not be slowed down. Then if directory B has over 100,000 files in it then create directory C, and on, and on.
Any good ideas/suggestions??
Thanks!
[email protected]
Re: The most efficient way to search a file
When it comes to manipulating files and folders they FileSystemObject comes in pretty handy... you'll need a reference to the Microsoft Scripting Runtime (SCRRUN.DLL)...
private Sub Command1_Click()
Dim fs as FileSystemObject
Dim f as Folder
set fs = new FileSystemObject
set f = fs.GetFolder("C:\Windows")
MsgBox "Folder " & f.Name & " has " & f.Files.Count & " files."
If fs.FileExists("C:\WINDOWS\WINSOCK.DLL") then
MsgBox "Winsock.Dll is in directory"
else
MsgBox "Winsock.dll isn't in directory"
End If
If f.Files.Count > 20 then
fs.CreateFolder ("C:\SomeNewFolder")
MsgBox "new Folder Created."
End If
End Sub
Re: The most efficient way to search a file
You can try using the APIs FindFirstFile and
FindNextFile
Regards,
Saurabh.