Computer Science Canada

How do you make the computer search through the directories for files using C++?

Author:  deathbow2134 [ Mon Jun 28, 2010 3:45 pm ]
Post subject:  How do you make the computer search through the directories for files using C++?

Programming with very basic C++ (the basic kind of applications that one on a command line), and you want the computer to search through the directories for certain files, how do you do that? (For example, searching the hard disk for files called "x" or something. :p)

Author:  USEC_OFFICER [ Mon Jun 28, 2010 4:25 pm ]
Post subject:  RE:How do you make the computer search through the directories for files using C++?

The search program? Looking for C++ file extendions? (Still can't spell.)

Author:  A.J [ Mon Jun 28, 2010 4:35 pm ]
Post subject:  RE:How do you make the computer search through the directories for files using C++?

Well, using standard File I/O, you could check for the existence of certain files by merely attempting to open files using it's extension (i.e. say if you are searching for the file 'Hello.txt' on your desktop, you merely have to attempt to open 'C:\Documents and Settings\Your_Name\Desktop\Hello.txt', or something).

But for this to work, make sure your program is in main directory of C Drive (well, in this particular example).

Author:  btiffin [ Mon Jun 28, 2010 4:46 pm ]
Post subject:  Re: How do you make the computer search through the directories for files using C++?

Very Operating System specific.

Either scan the weeb for some samples or look to the WinAPI for Windows under FindFirst FindNext. Under POSIX look to opendir readdir. Under OpenVMS you need to fill in NAM/FAB/RAB and maybe XAB RMS control blocks and call the appropriate system services. Etc...

Sure as tootin' somebody has pedagogic source code posted, or an ease of use library routine or ...

Cheers

Author:  bbi5291 [ Tue Jun 29, 2010 9:35 am ]
Post subject:  Re: How do you make the computer search through the directories for files using C++?

http://www.boost.org/doc/libs/1_43_0/libs/filesystem/doc/index.htm .


: