Accelerating “Find In Files” Visual Studio Search

Often times your solution may contain documents, pdfs and other items you don’t wish to search in.

I like using this filter set: *.cs;*.aspx;*.ascx;

Visual Studio Find In Files Filter

Update 10/5/2012. Jared recommended for broader searching: *.master;*.cs;*.aspx;*.ascx;*.asmx;*.asax;*.asp;*.inc;*.htm;*.html;*.config;*.css;*.xml;*.vb;*.resx;*.xsd;*.wsdl;*.svc;*.asa;*.js

Advertisements

Deleted Files Showing Up As Newly Added Files In Source Safe 6.0

When a particular person on your development team deletes a file managed under SourceSafe 6, the next time anyone else on that team Gets Latest Version those deleted files will show up in your Pending Checkins window as a “Newly added file” even though they are not.

To get around this, go into the Pending Checkins window and Check In all files.  The files that are truely deleted you will get prompted:

“A deleted copy of this FileNameHere.aspx file already exists in this project. Do you want to recover the existing file?”

A deleted copy of this FileNameHere.aspx file already exists in this project.  Do you want to recover the existing file?

Hit “Cancel” on these.  These are the files that have been deleted.

After checking in all files goto the Pending Checkins window and the remaining list of files still showing are the ones that have been deleted.

Pending Checkins only showing deleted files

Now if there was only a really nice easy way to mass delete from the Pending Checkins window!

SourceSafe v6.0 Process Notes

Initial Pull

  1. Right click on project | “Create Working Folder” (Which folder? %my docs\vs2008… or c:\inetpub\wwwroot ?
  2. Right click on project | “Get Latest Version” (choosing “recursive” and “Build tree” [only first time ])
  3. Load VS.net 2008 and goto Tools | Options confirming source control is set to “Microsoft Visual SourceSafe”
  4. Open local sln file pulled from source safe

Checking Out

  • Verify within Visual Studio –> Tools | Option | Source Control | Environment : if “On Save” and “On Edit” specify “Check Out Automatically” than code will automatically be checked out as you edit them

Checking In

  • View | Pending Checkings shows your pending check-ins can also check in here
  • Can also check in code by right clicking on file within solution explorer
  • Before checking in you’ll want to get latest code to ensure the build doesn’t break

Getting Latest Code

  • Within VS.NET 2008, You can either select the top level solution or the individual files. Right click and select the context menu “Get Latest Version”
  • For files you have checked out it will prompt you for the action you wish to perform, “Replace” or “Merge”
  • If you choose Merge, Source Safe will attempt to automerge. If it is unable to merge automatically it will prompt you to pick the changes to merge.

Performing Diffs from checked out code to code stored under Source Safe

  • Within VS.NET, right click on a file within solution explorer and click “View History”. Once you have history you can compare files.
  • if you wnat to compare yours to what is the latest in SourceSafe, you can right click the file and choose “compare”

SimpleLogging.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace Skippy
{
    //http://coercedcode.blogspot.com/2007/08/simple-logging-class-in-c.html

    //    This class is simple there are three static methods. One to write to a log file, one to write to the windows event log, and one to generate a log file name which can be used to create a log file in the directory which contains the executable of whatever application is calling it, or in the case of a web site it will be in the web site root directory.

    //Sample Usage:

    //Logging.WriteToEventLog("MyTestApp", "Testing", System.Diagnostics.EventLogEntryType.Information);

    //Logging.WriteToLog(Logging.GenerateDefaultLogFileName("MyTestApp"), "Testing");
    //This will give you a file named MyTestApp_8_16_2007.log in your application directory and log entries that look like this: 8/16/2007 3:35:52 PM Testing

    //If you look in your application event log you will see an entry like this: Event Type: Information Event Source: MyTestApp Event Category: None Event ID: 0 Date: 8/16/2007 Time: 3:35:54 PM User: N/A Computer: ComputerNameHere Description: Testing

    //Updated 8-1-2008 with using statement to dispose of the file stream in the event of a problem 




    public class Logging
    {

        public static string GenerateDefaultLogFileName(string BaseFileName)
        {

            return AppDomain.CurrentDomain.BaseDirectory + "\\" + BaseFileName + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + ".log";

        }
        


        /// <summary>
        /// Pass in the fully qualified name of the log file you want to write to
        /// and the message to write
        /// </summary>
        /// <param name="LogPath"></param>
        /// <param name="Message"></param>
        public static void WriteToLog(string LogPath, string Message)
        {
            try
            {
                using (StreamWriter s = File.AppendText(LogPath))
                {
                    s.WriteLine(DateTime.Now + "\t" + Message);
                    //s.WriteLine();
                    //s.WriteLine();
                }
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

        }





        /// <summary>
        /// Writes a message to the application event log
        /// /// </summary>
        /// <param name="Source">Source is the source of the message ususally you will want this to be the application name</param>
        /// <param name="Message">message to be written</param>
        /// <param name="EntryType">the entry type to use to categorize the message like for exmaple error or information</param>
        public static void WriteToEventLog(string Source, string Message, System.Diagnostics.EventLogEntryType EntryType)
        {
            try
            {
                if (!EventLog.SourceExists(Source))
                {
                    EventLog.CreateEventSource(Source, "Application");
                }

                EventLog.WriteEntry(Source, Message, EntryType);
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

        }

    }
}

FileInUse function

using System.Security.Permissions;
using System.IO;



public static bool FileInUse(string filePath)
        {
            try
            {
                if (!File.Exists(filePath))
                {
                    return true;
                }
                new FileIOPermission(FileIOPermissionAccess.Write, filePath).Demand();
                using (new FileStream(filePath, FileMode.Append))
                {
                    return false;
                }
            }
            catch (AccessViolationException)
            {
                return true;
            }
            catch (IOException)
            {
                return true;
            }
        }