Re: fast file count method?

Tech-Archive recommends: Fix windows errors by optimizing your registry



"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


.



Relevant Pages

  • Re: How to measure the amount of data generated on a server
    ... Download some trial software of message trending software. ... We have two Exchange Servers Exchange 2003 SP3. ... I am concerned about the amount of storage this is going to require and want ... counting the amount of 5 mb edb files created in a day. ...
    (microsoft.public.exchange.admin)
  • Re: low level local networking
    ... amount of time causing it too take 200ms minimum and a few more issues, ... With our own workarounds for indy9 its usable, ... had to put in the time to change it to another api i'd go for winsock atm. ...
    (borland.public.delphi.non-technical)
  • Re: fast file count method?
    ... Especially since windows index ... services are running on most PCs. ... Exactly how you go about counting them is a matter of some ... at the Win32 level and so will all take about the same amount of time. ...
    (microsoft.public.dotnet.framework)
  • RE: Web Services Processor Utilization
    ... The problem is taht you still don't know if the spike is caused by the ... service logic or by the logic you called through the API! ... >>> I have written a web service that returns an XmlDocument. ... >>> limit the amount of CPU used? ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Query virtual bytes
    ... an API I can add to my program to query the amount of virtual address my ... amount of virtual address space my single process has so far consumed. ... Bruce. ...
    (microsoft.public.win32.programmer.kernel)