Click here to Skip to main content
15,886,055 members
Articles / Programming Languages / C#

Visual Studio Cleaner and More

Rate me:
Please Sign up or sign in to vote.
4.86/5 (17 votes)
18 Dec 2011CPOL7 min read 60.7K   2.4K   55  
Delete junk files from Visual Studio solution/project by selecting files using search patterns
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace VStudioCleaner_ns
{
    public partial class HelpDialog : Form
    {
        public HelpDialog()
        {
            InitializeComponent();

            byte[] byteArray = Encoding.ASCII.GetBytes(helpHtml);
            MemoryStream mr = new MemoryStream(byteArray);
            this.webBrowser.DocumentStream = mr;

        }

        string helpHtml = 
"<html>" +
"<body lang=EN-US>" +
"" +
"<p><span style='font-size:12.0pt'>Filters are patterns used to select directories and files.</span>" +
"<p>" +
"<b><span style='font-size:12.0pt'>Patterns fall into four categories:</span></b>" +
"" +
"<ol>" +
"<li> <i>Directory</i> names" +
"<li> File <i>extensions</i>, matches files" +
"<li> <i>Wildcard</i>, matches directories and files" +
"<li> <i>Exclude</i> files or directories" +
"</ol>" +
"" +
"1. <b>Directory</b> pattern must end in a back slash." +
@" Example: <b><span style='color:red'>debug\</span></b>" +
"<br>" +
"Directory patterns only match on directory names and cause " +
"the directory and all of its subdirectories to be selected." +
"<p>2 File <b>extension</b> must start with a decimal point." +
" Example: <b><span style='color:red'>.obj</span></b>" +
"<br>File extension filter only matches on files." +
"<p>3. <b>Wildcard</b> is a collection of characters with one or more wildcard characters *. " +
"<br>Wildcard can appear multiple times. <b>*</b> matches zero or more characters." +
"<blockquote>" +
"Example: <b>Connect*.xml </b>" +
"<br>Example: <b>*foo*bar.* </b>" +
"</blockquote>" +
"<p>The wildcard pattern is tested against the fulll file or directory path so it is common for all wildcard patterns to start with <b>*</b> to match on any" +
" prefix of disk drive letters and subdirectories." +
"<p><blockquote>" +
"Examples:" +
"<br>" +
"<table border=1>" +
"<tr style=\"background-color:#c0c0c0;\"><td> Pattern <td>Test Against <td>Results" +
"<tr><td> foo*        <td>foobarcar              <td>match" +
"<tr><td> foo*        <td>carbarfoo              <td>no match" +
"<tr><td> *foo        <td>carbarfoo              <td>match" +
@"<tr><td> *foo\bin\*  <td>foo\junk               <td>no match" +
@"<tr><td> *foo\bin\*  <td>foo\bin\               <td>match" +
@"<tr><td> *foo\bin\*  <td>foo\bin\car.exe        <td>match" +
@"<tr><td> *\bin\*.obj <td>c:\foo\bar\bin\car.obj <td>match" +
@"<tr><td> *\bin\*.o*  <td>c:\foo\bar\bin\car.old <td>match" +
@"<tr><td> *\bin\*.o*  <td>d:\bin\junk.obj        <td>match" +
"</table>" +
"</blockquote>" +
"<p>A filter can contain one or more patterns separated by semicolons." +
"<blockquote>" +
@"Example: <b>Connect*.xml;.obj;obj\</b>" +
"</blockquote>" +
"<p>4. The <b>exclude</b> pattern is evaluated last and only for matches in the current filter. "+
"Exclude pattern starts with a <span style='color:red'>minus</span> sign." +
"<blockquote>" +
@"Example: <b>*\bin\*;</b><b><span style='font-size:12.0pt;color:red'>-</span>*.exe</b>" +
"</blockquote>" +
"<p>The above example will match on the directory &quot;<b>bin</b>&quot; and all of its subdirectories and files." +
" The exclude pattern will exclude all files with extension &quot;.<b><span style='color:red'>exe</span></b>&quot; from the matched files." +
" NOTE: the exclude only works on <b>File</b> and <b>Wildcard</b> filters and not simple <span style='color:red'>Directory</span> name filters." +
"<p>" +
"The following will <b><span style='color:red'>not</span></b> work because the members of bin directory are not tested individually." +
"<blockquote>" +
@"Example: <b>bin\;-*.exe</b>" +
"</blockquote>" +
"<p><b><span style='font-size:12.0pt'>Special Global Exclude Filter:</span></b>" +
"<p>If one or more exclude filters have their Filter name set" +
" to <b><span style='color:#E36C0A'>'never'</span></b>, they are always evaluated" +
" to prevent files from being located." +
"<p> " +
"<blockquote>" +
"Example:<br>" +
"<table border=1>" +
"<tr  style=\"background-color:#c0c0c0;\"><td>Filter <td>Example Pattern <td>Description" +
"<tr><td><b><span style='color:#E36C0A'>never</span></b><td> *.exe <td>Don't remove executables" +
"</table>" +
"</blockquote>" +
"<p>Use <b>Add</b> and <b>Delete</b> buttons to manage your collection of filter rules." +
"<br><b>Double click</b> on a row to change its value." +
"<br><b>Right click</b> if you want to Export the filter rules as CSV" +
"<p><b><span style='font-size:12.0pt'>Bookmarks:</span></b>" +
"<blockquote>" +
"<p>Use the bookmarks to memorize a set of filter rule checkmark states and Path setting." +
"<br>Use the bookmark <b>Add</b> button to add a new bookmark to remember the current settings. " +
"<br><b>Double Click</b> on a bookmark to activate its settings." +
"<br>Press the <b>Set</b> button to refresh the current state of a bookmark to the current list of active filter rules and Path." +
"</blockquote>" +
"<p><b><span style='font-size:12.0pt'>Search Path</span></b>" +
"<blockquote>" +
"Keep folder search path <b>empty</b> when you set a bookmark if you want its application to be applied to an existing path." +
"</blockquote>" +
"</div>" +
"</body>" +
"</html>";
            
        private void closeBtn_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) IBM / WSI
United States United States
I love C/C++ for its speed and power and C#/Visual Studio for quick application development.

Unix/Linux is my favorite OS

Android Studio is the best IDE I have used.

Comments and Discussions