I am writing a small utility to execute svn commands using c# program
Here is the key line in my program
System.Diagnostics.Process.Start("CMD.exe", @"svn checkout C:\TestBuildDevelopment\Code");
As I assume, the above code should be able to do svn check out and download all the code to the local path mentioned above. But what's happening is that, the command prompt opens up with the default path of the c# project and does nothing.
If I run this svn command in command line it works fine. But when I run using C# it just pops up the command prompt without executing the svn checkout operation. Any idea on what is going wrong?
You don t have to run CMD.exe. CMD.exe ist just a program that calls other assemblies. You can call svn.exe directly with your argument checkout ... (but isnt there a url missing?)
Process.Start("svn.exe", @"checkout C:\TestBuildDevelopment\Code");
you may also try this:
Process proc = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.RedirectStandardOutput = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "svn.exe";
startInfo.CreateNoWindow = true;
startInfo.Arguments = "checkout ...";
proc.StartInfo = startInfo;
if(proc.Start()) {
proc.WaitForExit();
}
You need to add the parameter /c. Try:
Process.Start("CMD.exe", @"/c svn checkout C:\TestBuildDevelopment\Code");
The parameter /c means that the cmd should execute the command and exit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With