I am trying to backup the database using mysql and c#
by using following way…
public static void backupDatabase()
{
Process sd = null;
ProcessStartInfo r1 = new ProcessStartInfo("C:\\Program Files\\MySQL\\MySQL Workbench 5.2 CE\\", "--databases=access --compress --routines --triggers --add-drop-database --add-drop-table --add-locks --extended-insert --port=3080 --user=root --disable-keys --quick --comments --complete-insert --result-file=DUMPEDOUTPUT.sql");
r1.CreateNoWindow = true;
r1.WorkingDirectory = "C:\\Program Files\\MySQL\\MySQL Workbench 5.2 CE\\";
r1.UseShellExecute = false;
r1.WindowStyle = ProcessWindowStyle.Minimized;
r1.RedirectStandardInput = false;
sd = Process.Start(r1);
sd.WaitForExit();
if (!sd.HasExited)
{
sd.Close();
}
sd.Dispose();
r1 = null;
sd = null;
}
got an exception at this line sd = Process.Start(r1);
Exception :{"The directory name is invalid"} Win32Exception Was unhandled
would any one pls help me guys
Many thanks In advance..
Modified Code :
public static void backupDatabase()
{
Process sd = null;
ProcessStartInfo r1 = new ProcessStartInfo("MySQLWorkbench.exe", "--databases access --compress --routines --triggers --add-drop-database --add-drop-table --add-locks --extended-insert --port=3080 --user=root --disable-keys --quick --comments --complete-insert --result-file=DUMPEDOUTPUT.sql");
r1.CreateNoWindow = true;
r1.WorkingDirectory = @"C:\Program Files\MySQL\MySQL Workbench 5.2 CE\MySQLWorkbench.exe";
r1.UseShellExecute = false;
r1.WindowStyle = ProcessWindowStyle.Minimized;
r1.RedirectStandardInput = false;
sd = Process.Start(r1);
sd.WaitForExit();
if (!sd.HasExited)
{
sd.Close();
}
sd.Dispose();
r1 = null;
sd = null;
}
I am getting same error at the same line ..
The first parameter to the
ProcessStartInfoshould be the executable you want to run. Right now you have it pointing to a directoryIt should probably be
You can also specifiy the path name by using
@in front of the string so you dont need to escape the backslashes. Like this:Update 1
Another thing to try, since you already specify the working directory, just put the executable name in the
ProcessStartInfoUpdate 2
Just noticed you added the exe filename to the
WorkingDirectory. This should just be the directory:But I think the issue is probably the permissions. My guess is the current user doesnt have permissions to this file path.