From: mapson AT mapson DOT com (Mapson) Newsgroups: comp.os.msdos.djgpp Subject: Re: Files In A Directory Date: Thu, 05 Nov 1998 16:34:05 GMT Organization: Yale University Lines: 37 Message-ID: <3641ceb8.6604853@news.cis.yale.edu> References: <354f26ae DOT 3464260 AT ct-news DOT iafrica DOT com> NNTP-Posting-Host: logan.eng.yale.edu X-Newsreader: Forte Free Agent 1.11/32.235 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Thu, 05 Nov 1998 14:51:42 GMT, quazar AT freemail DOT co DOT za (Marc Brooker) wrote: >Hi, > >I need to write a simple program to count the files in a directory, I >am currently using a program that is passed >count *.* >and it outputs the number of arguements, is there a better way to do >this? I don't know if it is better, but in a situation where I needed a count (as well as other information) I used something like this: ---------start code snippet-------- int done,TotalCount; struct ffblk f; char Filter[]="*.*"; done=findfirst(Filter,&f,FA_ARCH|FA_RDONLY|FA_HIDDEN|FA_SYSTEM); //count directory entries while (!done) { ++TotalCount; done = findnext(&f); } ----------end code----------- Incidentally, looking in that program, I also noticed that I used this function for checking if individual files exist: #include int __file_exists(const char *_fn); Hope that helps.