Question backup mysql database

altaf

New member
Joined
Mar 14, 2012
Messages
2
Programming Experience
Beginner
for backup i am provdng the code which i am running ....

  public void Backup()
{
  Process.Start("IExplore.exe");
    try
    {
        DateTime Time = DateTime.Now;
        int year = Time.Year;
        int month = Time.Month;
        int day = Time.Day;
        int hour = Time.Hour;
        int minute = Time.Minute;
        int second = Time.Second;
        int millisecond = Time.Millisecond;


        //Save file to C:\ with the current date as a filename
        string path;
        path = "C:\\MySqlBackup" + year + "-" + month + "-" + day + 
    "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql";
        StreamWriter file = new StreamWriter(path);


        
        ProcessStartInfo psi = new ProcessStartInfo();
        psi.FileName = "mysqldump";
        psi.RedirectStandardInput = false;
        psi.RedirectStandardOutput = true;
        psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}", 
            "root","123456","localhost","userdb");
       psi.UseShellExecute = false;


       Process process = Process.Start(psi);                              //here is exception comng when i run the code ......."The system cannot find the file specified"


        string output;
        output = process.StandardOutput.ReadToEnd();
        file.WriteLine(output);
        process.WaitForExit();
        file.Close();
        process.Close();
    }
    catch (IOException ex)
    {
        MessageBox.Show("Error , unable to backup!");
    }





when i run this code it is thrghng a exception at line ...........Process process = Process.Start(psi);
and exception is ................"The system cannot find the file specified"



plz help what i should do for successfully backup mysql database using c#



thanx
 
Last edited by a moderator:
Back
Top Bottom