Click to See Complete Forum and Search --> : I am thinking of making a disk utility...


DeepT
April 27th, 2009, 10:25 AM
That will map out where all your disk space being used, either by number of bytes being used, or number of files being used.

The first problem is finding out how much space is being consumed by directory X and all it's sub directories. I notice when you bring up the properties menu of a folder (or disk) that windows will very quickly come up with the totals. I am assuming that there is some kind of API call that ties into an existing database that can compile that information very quickly. If I manually crawled through program files, I think it would take far longer. Does anyone know what API call may be used for this information?

The second problem is graphing this information. I can come up with my own simple controls if I need to, but it would be much nicer to use pre-made controls to display this information. A Pie chart with labels would be great, but the only way I know of how to do this (circa .NET 2.0 ) is to use an excel assembly. The problem with this is that the end user needs to have excel installed to use my program. At worst I can use use a basic bar graph. With the new WPF stuff, are there some controls I can use to create a better graph?

Here is what I generally want to do:

My program starts at c: and gives you an "explorer like" view of the files and folders. Each folder / file will represent a portion of 100% of the disk space. I will hide the windows folder and not count it (I do not want some idiot deciding they are running Vista 64 bit therefor system32 is wasted space). At a glance you can see which folders contain the most % of disk space and file space. The user can now select files and folders to explore / delete ( many at this top level will be protected from deletion by from my program).

When you pick a folder to explore, it will become the new 100% and everything under it will be a % of that. And so on as you move around your file system.

The reason I want a tool like this is because of the frequency of uninstalling an application (such as a game you no longer play) and after it is uninstalled, there can still be 10s of 1000s of files left, taking GIGs of space just sitting somewhere in MyDocuments/.....Local/.../ApplicationYouRemoved/Data.

It would be nice if Windows added the concept of program ownership so you could track down all the files generated by X no matter how well hidden they might be.

Mutant_Fruit
April 27th, 2009, 11:38 AM
when you bring up the properties menu of a folder (or disk) that windows will very quickly come up with the totals. I am assuming that there is some kind of API call that ties into an existing database that can compile that information very quickly.

Try it on a folder with a few thousand files. It takes (literally) forever for it to give you the final total. It just recursively scans the directory structure and adds up the size of every file. When you do it on a folder with > 100,000 individual files (checking out code from svn duplicates each file), it can take a few minutes :)

Why not write something in silverlight ;) http://tirania.org/abrowser/SilverlightViewerTestPage.html

That's opensource too, so i'm sure you could quickly hack something together based on that. At the very least, it might give you ideas on what you want your app to look like.

DeepT
April 28th, 2009, 01:24 PM
Not quite 100,000 files, but "Program Files (x86)" 49,817 files, 5,323 folders - 3 seconds. Oh well. Doing this myself will just be very grindy, and if I want to keep a database of all this for "faster" searching, its going to be huge. It might take as long to load (if I use XML) as to just read file stats from the disk raw. All that string parsing would be a killer.

I wonder if it might be better to have a watchdog program run when you install stuff that can make a database of all the files that are installed and furthermore, any of those files (which happen to be programs) also create.

I know there is a win32 way to watch a disk for file changes, and I also know that there is a huge amount activity to monitor, let alone correlating who did what. IE: I want to know when files are created, but only by process X, Y, and Z.

Mutant_Fruit
April 28th, 2009, 05:56 PM
It just took me 6 or 7 seconds to calculate the info for my 'Programming' folder, which only contains 1875 files, 947 folders, 722MB size (68.3mb size on disk). It's really HD dependent. Max out your HD with dozens of small writes and keep that up while calculating the size of a folder. It'll defintely take forever then ;)

Wow, tiny text files are really bloated :P