I am trying to automate svnadmin dump using C # ProcessStartInfo.
Like I did on the command line, so,
svnadmin dump c:\Repositories\hackyhacky > c:\backup\hackyhacky.svn_dump
Works with processing and dumps successfully, and I can verify this by restoring it to another repository like
svnadmin load c:\Repositories\restore_test < c:\backup\hackyhacky.svn_dump
What is restored successfully - yay!
Now ... I need to replicate the command line pipeline to another file using C #, but for some reason
var startInfo = new ProcessStartInfo(Path.Combine(SvnPath, "svnadmin"),"dump c:\Repositories\hackyhacky")
{CreateNoWindow = true, RedirectStandardOutput = true,RedirectStandardError = true,UseShellExecute = false};
process.StartInfo = startInfo;
process.Start();
StreamReader reader = process.StandardOutput;
char[] standardOutputCharBuffer = new char[4096];
byte[] standardOutputByteBuffer;
int readChars = 0;
long totalReadBytes = 0;
using (StreamWriter writer = new StreamWriter(@"C:\backup\hackyhacky.svn_dump", false)) {
while (!reader.EndOfStream) {
readChars = reader.Read(standardOutputCharBuffer, 0, standardOutputCharBuffer.Length);
standardOutputByteBuffer = reader.CurrentEncoding.GetBytes(standardOutputCharBuffer);
writer.Write(standardOutputCharBuffer.Take(readChars).ToArray());
totalReadBytes += standardOutputByteBuffer.Length;
}
}
Flushes the same repo in hackyhacky.svn_dump.
But when I run my boot command line
svnadmin load c:\Repositories\restore_test < c:\backup\hackyhacky.svn_dump
I get weird-error checksum error!
svnadmin load c:\Repositories\restore_test < c:\backup\hackyhacky.svn_dump
< Started new transaction, based on original revision 1
* adding path : Dependencies ... done.
* adding path : Dependencies/BlogML.dll ...svnadmin: Checksum mismatch, fil
e '/Dependencies/BlogML.dll':
expected: d39863a4c14cf053d01f636002842bf9
actual: d19831be151d33650b3312a288aecadd
I assume this is due to the way I redirect and read StandardOutput.
Does anyone know the correct way to simulate the behavior of strings on the command line in C #?
Any help is greatly appreciated.
-cv
UPDATE
BinaryWriter standardOutputByteBuffer , . - .