Note that there are some explanatory texts on larger screens.

plurals
  1. POCalculating directory sizes
    text
    copied!<p>I'm trying to calculate directory sizes in a way that divides the load so that the user can see counting progress. I thought a logical way to do this would be to first create the directory tree then do an operation counting the length of all the files.</p> <p>The thing that comes to me as unexpected is that the bulk of time (disk I/O) comes from creating the directory tree, then going over the <code>FileInfo[]</code> comes nearly instantly with virtually no disk I/O.</p> <p>I've tried with both <code>Directory.GetDirectories()</code>, simply creating a tree of strings of the directory names, and using a <code>DirectoryInfo</code> object, and both methods still take the bulk of the I/O time (reading the MFT of course) compared to going over all the <code>FileInfo.Length</code> for the files in each directory.</p> <p>I guess there's no way to reduce the I/O to make the tree significantly, I guess I'm just wondering why this operation takes significantly more time compared to going over the more numerous files?</p> <p>Also, if anyone could recommend a non-recursive way to tally things up (since it seems I need to just split up the enumeration and balance it in order to make the size tallying more responsive). Making a thread for each subdirectory off the base and letting scheduler competition balance things out would probably not be very good, would it?</p> <p>EDIT: <a href="https://github.com/jihyq9/DirectorySizeBrowser" rel="nofollow">Repository for this code</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload