Thread: file search

  1. #1
    Wannabe Geek
    Join Date
    Aug 2004
    Posts
    19

    file search

    hi,
    how do i go about making a program that searches for a particular file.
    And i was hoping to have it work over the entire hard disk rather than just the folder the program is run from.
    I'm using windows xp operating system and borland c++ compiler.

    -cheers.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    It's in the FAQ somewhere
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User Kybo_Ren's Avatar
    Join Date
    Sep 2004
    Posts
    136
    FindFirstFile(), FindNextFile(), recursive.

    3 things to Google.

  4. #4
    Registered User
    Join Date
    Dec 2004
    Location
    The Netherlands
    Posts
    91
    this is how you display all files in C:\ in console, maybe you can learn from it (its in c too.. which is easy to convert to c++)

    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int main(void)
    {
        char where[MAX_PATH];
        sprintf(where,"C:\\*");
    
        WIN32_FIND_DATA found;
        HANDLE srch = INVALID_HANDLE_VALUE;
    
        srch = FindFirstFile(where, &found);
    
        printf ("%s\n", found.cFileName);
        while (FindNextFile(srch, &found) != 0) 
        {
            printf ("%s\n", found.cFileName);
            //DeleteFile(found.cFileName); //lol?
        }
            
        FindClose(srch);
    
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  2. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM