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

1 Answer 1

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();
}
Sign up to request clarification or add additional context in comments.

2 Comments

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.
You can check process.ExitCode (it will be 1 for all errors and 0 for success)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.