Hi,
I'm trying to run mysqldump.exe from my c# application, running on windows
vista with visual studio 2005.
The following code does not produce the output file. The same line used in a
command prompt works fine.
While debugging, I get an exception "InvalidOperationException, StandardOut
has not been redirected or the process hasn't started yet." when attempting
the System.Console.Write(p.StandardOutput.ReadToEnd() line.
I get no exception but an output line of "mysqldump: Got errno 9 on write"
when attempting the System.Console.Write(p.StandardError.ReadToEnd())
command.
If I use a largish database and dont turn on the redirections, I appear to
get the output to the console rather than to file, but the text flashes by
so fast I can't read what's on the first few lines.
I don't know if it's something Im doing wrong, or vista. Is anyone able to
help please.
mysqldumpstring = @"--user=root --password=masterkey --hex-blob --databases
test c:\temp\claire_dump.sql";
Process MySQLDump = new Process();
ProcessStartInfo info = new ProcessStartInfo("mysqldump.exe");// mysqldump
is in environment path
info.Arguments = mysqldumpstring;
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardError = true;
Process p = Process.Start(info);
p.WaitForExit();
try
{
System.Console.Write(p.StandardOutput.ReadToEnd()) ;
}
catch { }
try
{
System.Console.Write(p.StandardError.ReadToEnd());
}
catch { }