try { DateTime backupTime = DateTime.Now; int year = backupTime.Year; int month = backupTime.Month; int day = backupTime.Day; int hour = backupTime.Hour; int minute = backupTime.Minute; int second = backupTime.Second; int ms = backupTime.Millisecond; String tmestr = backupTime.ToString(); tmestr = "D:\\" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + ".sql"; StreamWriter file = new StreamWriter(tmestr); ProcessStartInfo proc = new ProcessStartInfo(); string cmd = string.Format(@"-u{0} -p{1} -h{2} {3} ", "root", "sa", "localhost", "employee", "backup.sql"); proc.FileName = @"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump"; proc.RedirectStandardInput = false; proc.RedirectStandardOutput = true; proc.Arguments = cmd;//"-u root -p smartdb > testdb.sql"; proc.UseShellExecute = false; Process p = Process.Start(proc); string res; res = p.StandardOutput.ReadToEnd(); file.WriteLine(res); p.WaitForExit(); file.Close(); MessageBox.Show("Backup Done"); } catch (IOException ex) { MessageBox.Show("Disk full or other IO error , unable to backup!"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)