Get the full path of running process in C#.

public static string GetProcessPath()
{
    // fix the path so that if running under the debugger we get the original file.
    string processName = Process.GetCurrentProcess().MainModule.FileName;
    int index = processName.IndexOf("vshost", StringComparison.Ordinal);
    if (index != -1)
    {
        string first = processName.Substring(0, index);
        int numChars = processName.Length - (index + 7);
        string second = processName.Substring(index + 7, numChars);
        processName = first + second;
    }

    return processName;
}