[Tutor] Looking for something similar to du...

Alan Gauld alan.gauld at btinternet.com
Tue May 6 08:55:10 CEST 2008


"Marc Tompkins" <marc.tompkins at gmail.com> wrote

>> Can you explain what you mean by the diffrence between the size
>> used versus the size of the image?
> Disk space is allocated in large units (in DOS/Windows they're 
> called
> "clusters", *nixes call them "blocks").

Ah yes, indeed it is. And in a previous life I even used
to care about such things!

Nowadays I've gotten used to disk space being so
cheap and plentiful I confess I'd forgotten all about
the diffrences and their significance.

Thanks for the reminder Marc.

As to finding disk usage on Windows I found this
snippet on an MSDN forum:

------------------
If you want the size of the file on disk when compressed or sparse
then you have to use Platform/Invoke to call GetCompressedFileSize
as I don't believe .NET exposes this method directly.  Furthermore
this doesn't give you the actual size on disk if it isn't compressed.
For that I believe you'd have to determine how many clusters it
takes up and multiply that by the cluster size.  I don't believe
there is any direct way in Windows to do that but WMI might
provide a way.  Nevertheless this is not what you'd want to
use as it'll also contain unused bytes of data.
---------------------

Which is rather scary...

Alan G 




More information about the Tutor mailing list