Searching files in folder

S

Steffen Loringer

Hi group,

may be a simple question: How can I find out in C, which files of a
specified extension exist in a specified folder? My app should
constantly look for a file with an known extension but unknown name. A
link with an example would be nice

Thanks a lot for help

Steffen
 
P

Pravin Paratey

It really depends on what platform you're coding for.

On windows, take a look at FindFirst and FindNext APIs
 
F

Flash Gordon

Steffen said:
Hi group,

may be a simple question: How can I find out in C, which files of a
specified extension exist in a specified folder? My app should
constantly look for a file with an known extension but unknown name. A
link with an example would be nice

You can't in standard C. You will have to ask in a group dedicated to
your platform for the platform specific extensions (if they exist) that
will allow you to do this.

<OT>
On some systems there are far better ways than continually looking for
the files, on other systems you will have to continually read the
directory, and on some systems files don't even *have* extensions.
</OT>
 
E

Emmanuel Delahaye

Steffen Loringer wrote on 25/07/05 :
Hi group,

may be a simple question: How can I find out in C, which files of a specified
extension exist in a specified folder? My app should constantly look for a
file with an known extension but unknown name. A link with an example would
be nice

The is no standard C answer. However, opendir() readdir() is POSIX.1
hence available on many platforms.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

..sig under repair
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,167
Messages
2,570,911
Members
47,453
Latest member
MadelinePh

Latest Threads

Top