On Mon, May 5, 2008 at 11:55 PM, Alan Gauld <[EMAIL PROTECTED]> wrote:
> > 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... > Not really, just written by someone who 1) had something else in mind, or 2) is unclear on the concept. Because _of course_ this number will include unused bytes (not "of data", though, just "of disk space"). It's called slack space, I believe - all those extra bytes between the end of the file and the end of the last cluster allocated to the file. Even with FAT32, NTFS, and many highly-advanced file systems in the *nix world, it adds up to a surprisingly large proportion of most peoples' disk space. (More if you have lots of tiny files, less if you have lots of big files.) That being said, I've recently been buying 500GB hard drives for $100. (And yes, I'm sure there are even hotter deals out there. Don't rub it in if you've found one, though - it'll only make me miserable.) At 20 cents a gig, it's hard to work up any real anxiety over slack space. I'm curious - what does the OP do with this info? Does it have some deeper significance I don't know about, or is it just a cool statistic to track? -- www.fsrtechnologies.com
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor