What is taking up the space on your hard disk? TreeMap it!

Several years ago, I saw a presentation from Microsoft Research about online communication in communities . In particular, a group was studying online communities based on NewsGroup message traffic volume. One of the results was a graphical view of the newsgroups called Netscan.

I didn’t think much of it til I received a comment on my blog Running out of space ? What's on your disk? in which I showed some code to put into a table the folders and their sizes on your hard disk. The comment pointed to a web site showing a Treemap to display disk space usage.

So, it was fairly easy to make a program that shows a map of my hard disk in a treemap. This is a sample treemap of my “c:\Program Files\” folder.

 

The treemap shows rectangles for each folder. Each rectangle is divided alternately horizontally or vertically, into subrectangles for each subfolder proportional in size to the folder. Hovering the mouse over a rectangle shows the folder path and size in a tooltip. The leftmost large block that takes the entire height shows that almost 1/3rd is taken up by Visual Studio 2003. The top left light blue large block is “Visual Studio 2003\vc7\atlmfc\lib” The next large vertical band is “Program Files\Common Files” with a couple speech engines and the one after is “Program Files\Microsoft Office”

A folder can contain files and folders. If a folder contains 5 subfolders and 10 files, it will have 6 subrectangles: 1 for each subfolder and 1 for the files (labeled with “*\” at the end)

Each folder is a MyRect object subclassed from Shape and added to the form, so there could be thousands of objects.

Try clicking on a folder: the MyRect Click event creates a new instance of the form drilling down one level deeper into that Rectangle.

The code to generate the Treemap (about 100 lines) in HTML is here and the raw prg is here. You can modify the code to add features delete folders that are right clicked on, use colors to show last used dates, show folder names on the rectangles, etc.

(Thanks to John Koziol for feedback on this code)

67877