Start a second copy of the program with the same arguments
<p>What is the correct way for a application to restart another copy of itself with the same arguments?</p>

<p>My current method is to do the following</p>

<pre><code>static void Main()
{
    Console.WriteLine("Start New Copy");
    Console.ReadLine();

    string[] args = Environment.GetCommandLineArgs();

    //Will not work if using vshost, uncomment the next line to fix that issue.
    //args[0] = Regex.Replace(args[0], "\\.vshost\\.exe$", ".exe");

    //Put quotes around arguments that contain spaces.
    for (int i = 1; i &lt; args.Length; i++)
    {
        if (args[i].Contains(' '))
            args[i] = String.Concat('"', args[i], '"');
    }

    //Combine the arguments in to one string
    string joinedArgs = string.Empty;
    if (args.Length &gt; 1)
        joinedArgs = string.Join(" ", args, 1, args.Length - 1);

    //Start the new process
    Process.Start(args[0], joinedArgs);
}
</code></pre>

<p>However it seems like there is a lot of busy work in there. Ignoring the striping of the vshost, I still need to wrap arguments that have spaces with <code>"</code> and combine the array of arguments in to a single string.</p>

<p>Is there a better way to launch a new copy of the program (including the same arguments), perhaps a way just needing to pass in <a href="http://msdn.microsoft.com/en-us/library/system.environment.commandline">Enviroment.CommandLine</a> or takes a string array for the arguments?</p>
