Difficulty with System.Diagnostics.Process and MySqlDump

  • Thread starter Thread starter dwcscreenwriterextremesupreme
  • Start date Start date
D

dwcscreenwriterextremesupreme

I am trying to automate a mysqldump backup through C# and for some
reason the System.Diagnostics.Process is just not working as expected
for me.

What I want is for the following code to start a mysqldump, wait there
until it finishes, and then continue the loop.

foreach (DataRow dataRow in backupdt.Rows)
{
System.Diagnostics.Process proc = new
System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
backupFilename = "c:\\data\\" +
dataRow["EntBkpSrvName"].ToString() + "." +
dataRow["EntBkpDbName"].ToString() + "." +
DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +
DateTime.Now.Day.ToString();
dumpString = " -h" + dataRow["EntBkpSrvIP"].ToString() + " -
uusername -ppassword " + dataRow["EntBkpDbName"].ToString() + " > " +
backupFilename + ".sql";
proc.StartInfo.FileName = "mysqldump.exe";
proc.StartInfo.Arguments = dumpString;
proc.Start();
proc.WaitForExit();
}


Can someone tell me what I'm doing wrong?

Thanks.
 
Without knowing what is going wrong (you say it is not working as
expected for you, but what exactly is wrong) it's impossible to say.

Can you clarify?
 
Back
Top