Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

svn check out using C# program

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?

like image 762
SARAVAN Avatar asked Jul 29 '26 13:07

SARAVAN


2 Answers

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();
}
like image 111
Florian Avatar answered Jul 31 '26 02:07

Florian


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.

like image 36
rekire Avatar answered Jul 31 '26 04:07

rekire



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!