Posts Tagged ‘system’

TreePie is dead, long live TreePie

Monday, March 2nd, 2009

OK, so TreePie isn’t quite dead, you can still use it perfectly well if you run Windows XP but there hasn’t been a release since 1.2 came out in April 2008 and even that doesn’t work on Vista.

I set about writing my own small version of TreePie in C#, using the System.IO namespace to index files as this should work on any version of Windows that can run the .net framework. Compatibility is the whole point in me making this in the first place.

The idea behind TreePie is simple. It shows a hierarchical pie chart of your file system based on file sizes. In Windows, there is no simple way of getting a directory’s size. The size of a directory is equal to the sum of the sizes of the files in that directory plus the sum of the sizes of its subdirectories. This is obviously a recursive operation so if you want to know the size of C:\ you need to know the size of C:\Users and C:\Windows and to know the size of C:\Windows you need to know the size of C:\Windows\System32, C:\Windows\System and so on. TreePie shows many levels of the directory structure in one pie chart but I am keeping this quick and simple.

My version of this colours pie segments randomly and highlights the segment you are hovering over with 50% opacity. Finding the segment you are hovering over is relatively simple. In C#, you catch the MouseMove event of the PictureBox. You find the centre coordinates of the pie (in case you have margins or whatever) then calculate the distance of the cursor from that point with Pythagoras (a2 + b2 = c2) and check if it is more than the radius of the pie. This is the same way that circular or spherical collisions are detected in games. Next, you get the angle with the atan2 function and can find which segment it corresponds to from there. For efficiency, the pie should only be redrawn when the hovering segment changes (if any highlighting is used). You can go into a directory by clicking on the segment and go up a directory by right clicking anywhere on the pie. The application caches sizes so when you enter a child segment it never has to re-load anything and when you go to a parent segment, it does not have to re-load the child you just came from at the very least.

TreePie is useful to find out where your hard drive space is being used. If you want to free up some space, it is excellent for finding the biggest directories so that you know what to move to a different hard drive or delete entirely.

The following shows my own user directory with the mouse cursor hovering over AppData (the teal segment that takes up nearly half of the pie). AppData should not really be this big in comparison to directories such as Documents (red) or Downloads (blue).

treepie1

If we click on AppData, it shows us that 88.6% of it is used by the directory “Local” and if we click on “Local” we find the real culprit, the “Temp” directory. In theory, files should be removed from this directory when the application that created them closes but this isn’t always the case.

treepie2

When I view this directory in Windows Explorer, I can see that there is one very large installer file in here that had been extracted, installed from and then not removed. It is a simple matter to run the Windows Disk Cleanup utility on my C: drive to clean this out safely.

Download