Re: fast file count method?
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Wed, 21 Jun 2006 16:17:37 -0700
"Luca Beretta" <LucaBeretta@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C834CC43-5653-45F3-AC92-C08A7A46C672@xxxxxxxxxxxxxxxx
the managed way is :
System.IO.DirectoryInfo dinfo = new
System.IO.DirectoryInfo("c:\\windows");
int filecount = dinfo.GetFiles().Length;
otherwise you need to PInvoke C++ function from Win API.
.... which will be just as slow as the method the OP suggested.
In short, no - there's no faster way to get a full count of files than by
counting them. Exactly how you go about counting them is a matter of some
debate, but they'll all boil down to calls to FindFirstFile/FindNextFile at
the Win32 level and so will all take about the same amount of time.
You can use the class described in this article:
http://www.codeproject.com/cs/files/FileSystemEnumerator.asp
to count files as well - it will take the same amount of time as the methods
described above, but it won't take as much memory since it doesn't return a
string[] of file names.
-cd
.
- Follow-Ups:
- Re: fast file count method?
- From: Rob R. Ainscough
- Re: fast file count method?
- References:
- fast file count method?
- From: Rob R. Ainscough
- fast file count method?
- Prev by Date: Re: GC and dispose
- Next by Date: Re: Problem with EventHandlers
- Previous by thread: fast file count method?
- Next by thread: Re: fast file count method?
- Index(es):
Relevant Pages
|