By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,189 Members | 2,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,189 IT Pros & Developers. It's quick & easy.

Searching files in folder

P: n/a
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

Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
It really depends on what platform you're coding for.

On windows, take a look at FindFirst and FindNext APIs

--
pravin

Nov 15 '05 #2

P: n/a
Steffen Loringer <st**************@freenet.de> wrote:
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


<http://www.eskimo.com/~scs/C-faq/q19.20.html>.

Richard
Nov 15 '05 #3

P: n/a
Steffen Loringer wrote:
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>
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #4

P: n/a
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
Nov 15 '05 #5

P: n/a
Steffen Loringer wrote:
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


If you're developing for Windows you can use FindFirstFile() &
FindNextFile().

-Mike
Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.