1

I am trying to back up my reposotries using a C# Code

        Process svnCommand = null;
        var psi = new ProcessStartInfo("svnadmin");
        psi.RedirectStandardOutput = true;
        psi.RedirectStandardError = true;
        psi.UseShellExecute = false;
        psi.Arguments= @"dump C:\Repositories\Myrepo > C:\temp\myrepodumpfile.dump";

        using (svnCommand = Process.Start(psi))
        {     
            var myoutput = svnCommand.StandardOutput;

            var myerror = svnCommand.StandardError;



            Debug.Write("Output :" + Environment.NewLine +
                Environment.NewLine + myoutput.ReadToEnd() +
                Environment.NewLine + "Error :" +
                Environment.NewLine + Environment.NewLine +
                myerror.ReadToEnd());

            svnCommand.Close();
        }

When i use the dump command from the commandline

svnadmin dump C:\Repositories\Myrepo > C:\temp\myrepodumpfile.dump

it works fine but when i try to use it through C# code given above it gives error as

svnadmin: E205000: Try 'svnadmin help' for more info
svnadmin: E205000: Too many arguments

My SVN info :

SVN version 1.7.5 Environment variable aslo set (i can use sv directly from cmd)

Cant seem to figure out whats the problem

Ankesh
  • 4,847
  • 4
  • 38
  • 76

1 Answers1

3

> is a feature of the command line; you can't use it when launching a process from C#.

What > does is it takes the output that the process writes to StandardOutput and writes it to a file. That's what you need to also implement in your program, e.g.

var psi = new ProcessStartInfo("svnadmin");
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.UseShellExecute = false;
psi.Arguments= @"dump C:\Repositories\Myrepo";

using (var svnCommand = Process.Start(psi))
{     
    var myoutput = svnCommand.StandardOutput;

    File.WriteAllText(@"C:\temp\myrepodumpfile.dump", myoutput.ReadToEnd());

    svnCommand.WaitForExit();
}
dtb
  • 213,145
  • 36
  • 401
  • 431
  • 1
    Thanks it worked ... but i have one query... `svnadmin dump` reports success and failure in the `StandardError` stream. how will i know that the dumped is successful or not. – Ankesh Jun 29 '12 at 09:04
  • You can check `process.ExitCode` (it will be 1 for all errors and 0 for success) – hadaco May 26 '15 at 10:29