Introduction

If you publish or share your software, or are just a neat freak and like to keep your disk clean, you will appreciate this utility to remove superfluous files. Visual Studio generates extra files which can be safely deleted because they are either automatically generated or are produced when you build your solution. This utility is based off of the CodeProject "VS.NET Solution Cleaner" by Leonardo Paneque and borrows some behavior from "Wise Cleaner". VstudioCleaner is basically a file and directory search engine which presents the results for deletion. The search 'filters' can be changed. Groups of filter settings can be associated with 'bookmarks' for quick recall. My personal hang ups with other applications are the inverse of the following features I offer and guidelines I try to adhere to when creating software.

All dialogs should allow resizing (and look good when size is increased)

Avoid modal dialogs

List/tables should support column sorting and multiple selection

Drag and Drop (though this app has no specialized implementation)

Export - make it easy to export information in a simple form (Text or CSV)

Remember configuration changes

Ideally the program should be a single executable

This program is more than just a Visual Studio cleaner because the filters are expandable. You can create your own set of filters and bind them to a bookmark for easy recall. You can use it to cleanup your browser droppings.

How To Use

To use VStudioCleaner, you need to set the search Path to one or more directories and select one or more filters. The search "path" can be set by either typing in the path, cut & paste a path or using the Path... button to browse and select a path. If you need to specify multiple paths, you cannot use the Path... button because it does not append, it only knows how to set the search path. Multiple directory (folder) paths are specified by separating them by semicolon, as in:

c:\dir1;c:\dir2\subdir1;d;\dir3\subdir2;e:\

You set your filters by either 'checking' or 'unchecking' the built-in filters or by adding your own filters. Once the search "Path" and "Filters" are set, press the "Locate" button to build up a list of files and directories. The resulting list will appear in its own dialog. You can sort the various columns (why, directory, file, extension, size) and right-click to remove files from the list. The right-click remove action only removes the names from the list, it does not remove anything from your computer. Once you have your list of files pruned down to those you want to delete from your computer, you can press the "delete" button.

Warning - The delete action is permanent. The files will NOT appear in the Recycle Bin.

Filters

Filters are patterns used to select directories and files. Filters fall into three categories:

Directory names, match directory and select all files and subdirectories

File extensions, matches files

Wildcard, matches directories and files

Directory filters must end in a back slash. Example: debug\Directory filters only match on directory names and cause the directory and all of its subdirectories and files to be selected.

A filter rule can contain one or more filters separated by semicolons. Example: Connect*.xml;.obj;obj\

Use "Add" and "Delete" buttons to manage your collection of filter rules. Double click on a row to change its value. Right click if you want to Export the filter rules as CSV.

Bookmarks

Use the bookmarks to memorize a set of filter rule checkmark states and Path setting. Use the bookmark Add button to add a new bookmark to remember the current settings. Double Click on a bookmark to activate its settings. Press the "Set" button to refresh the current state of a selected bookmark to the current list of active filter rules and Path.

Keyboard

Control-A to select entire List

Space to toggle check boxes

Delete key to delete selected items or item under mouse

Up/Down to navigate up/down list and select row

Warning

No undo to restore items removed from a list or any undo to restored DELETED files or directories. Deleted files and directories will not appear in your recycle bin so you have no way to undo your deletions.

Sample screen of File and Directory List Located using default filters:

Points of Interest

While writing this application, I learned the following:

How to launch RegEdit and get it to open on a specific registry entry

How to force a listview to scroll to the left

Registering VStudioCleaner to folder menu

Recursive pattern matcher

Inline HTML help viewer

RegEdit, like most Windows applications, saves session settings in the registry. Before you launch RegEdit, you simply set the value of LastKey in section Software\Microsoft\Windows\CurrentVersion\Applets\Regedit to the registry path of your entries.

The second trick "to scroll listview left" was required when a user is editing a row in a ListView. Depending on the size of the UI, it is possible that part of the row is not visible. Before a column is edited, I wanted it to be in view so I had to scroll the listview to the left. Here is the code I use to send keys to the UI in focus.

VStudioCleaner can be registered to appear in the Shell Folder popup menu.

Example of Option menu showing register selection:

Once VstudioCleaner is registered to the shell folders, you can right click on a folder and easily launch VStudioCleaner on that folder. The folder path will appear as its default search path. Below is an image of the menu which appears when you right-click on a folder. This trick is thanks to "Leonardo Paneque" and his CodeProject "Solution Cleaner". Using trick #1 above, VStudioCleaner has menu picks to open the Windows Registry in both the section where VStudioCleaner stores its session info as well as the Shell Folder menu settings.

Sample of menu when you right-click a folder, showing VStudioCleaner:

This program also includes a simple wildcard pattern matching engine. It only supports a single specialized wildcard '*' but the wildcard can appear multiple times in the pattern.

Because the pattern matching is complex I added a popup help dialog, launched by pressing the "?" button. The original version used a RichTextBox. I found it painful to setup font size and colorization, so I switched in version v1.5 to HTML. I wanted to keep vstudtiocleaner a single program and did not want a CHM or HTML help file. Since my help text is reasonably short, I just embedded it in the program. Here is part of the code in helpdialog.cs.

Comments and Discussions

30 years experience writing software.
I love C/C++ for its speed and power and C#/Visual Studio for quick application development.

and than this ...

While writing this application, I learned the following:
1.How to launch RegEdit and get it to open on a specific registry entry
2.How to force a listview to scroll to the left
3.Registering VStudioCleaner to folder menu
4.Recursive pattern matcher

Most of my coding was on a powerful OS like Linux using C++.
I have only had to suffer under Windows the last few years. And with switching OS and language, you need to learn the basics....
I think #1 was one that is not found on the web.

If you downloaded v1.8 updated on Dec 17 at 4pm, you should get the next update which Code Project will post shortly. The Dec 17 post had a bug handling mixed case correctly. The subsequent post will ignore the case of the directories and files during the pattern matching. I also added colors to the default settings.

Before complaining: Great job extending to Paneque's idea. I really like yours.

I tried using your software to clean up subversion data folders. It successfully finds the files I want to delete, but when I click delete, aparently deletes the files, but actually does nothing, and I get no error message. Maybe you're silently eating some exceptions...Is there a way to know if something fails, that it has, and why???

There is a try/catch block around the deletion. See code lines 966-981 in FileScan.cs
If an exception occurs when a file or directory is deleted, it will be caught and the line in the list view will change color to RED and include the exception error message. When all of the deletions have completed, what is left should be RED and include the exception error messages. If you are not seeing any errors, then C# thinks the deletion has completed.
You may have to resize the list view to see the full exception error message.

Thanks for the bug report.
I believe the duplicate filter name logic is the cause of the problem.
I will either have to allow variations on the 'never' filter name or I will have to allow duplicate filter names.
I will report back with a solution later.

I try to add art to all my programs. I start by using Google to locate images. I then cut and paste the parts I like, change colors, and scale. On my home page I created a short animated GIF of the scrubbing bubble.