Folder size

  • Thread starter Thread starter mc
  • Start date Start date
M

mc

I need to do a simple program to monitor the size of a folder directory.
The size can flutuate from 1 Kb to 500Gb.
what is the best way to implement this?
 
If you don't want to wait the time to loop through all the files and get their size, you could write a service which had a FileSystemWatcher in it to constantly update a database with changes in files. Any changes to any files in the folder can be caught by it. I once did exactly that but didn't really need to use it, so it got put to the back of the shelf.
I need to do a simple program to monitor the size of a folder directory.
The size can flutuate from 1 Kb to 500Gb.
what is the best way to implement this?
 
FileSystems are databases and throwing something into a database just
results in replication of the data. The database still has to run an expensive
query over the file information, albeit, maybe tuned to be faster than file
acesss, but the file access in this case can be heavily sped up by calling
Win32 API's directly.

Check out PInvoke.net and look for FindFile and FindNextFile.... You can
quickly enumerate a recursive directory structure and build a size list in no
time, even with 500GB's of MP3s ;-) j/k


--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Bonj" <benjtaylor at hotpop d0t com> wrote in message If you don't want to wait the time to loop through all the files and get their size, you could write a service which had a FileSystemWatcher in it to constantly update a database with changes in files. Any changes to any files in the folder can be caught by it. I once did exactly that but didn't really need to use it, so it got put to the back of the shelf.
I need to do a simple program to monitor the size of a folder directory.
The size can flutuate from 1 Kb to 500Gb.
what is the best way to implement this?
 
Back
Top