CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Location
    New York, USA
    Posts
    169

    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]

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    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





  3. #3
    Join Date
    Jul 2001
    Location
    Mumbai,India
    Posts
    382

    Re: The most efficient way to search a file

    You can try using the APIs FindFirstFile and
    FindNextFile

    Regards,
    Saurabh.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured