When i’m trying to take a database Backup or Restore means it is not working properly. because the path which i given contains ‘SPACE’
BackUp/RestoreFile Path: “C:\Documents and Settings\prabhu\Desktop\Backup.sql“
(Documents and Settings contains ‘SPACE’)
I’m Working in C#.
CODE:
string directoryName = D:\\Shop Plan\\ERP Project\\Main Source\\OutPut\\Debug\\DBBackup;
string filePath = "C:\Documents and Settings\prabhu\Desktop\Backup.sql";
TextWriter textWriter = new StreamWriter(filePath);
textWriter.WriteLine("CD " + directoryName);
if (type == "Backup")
{
textWriter.WriteLine("mysqldump -h " + "SERVERNAME"+ " -u " + "USERNAME" + " -p" + "PASSWORD" + " -P " + "PORT" + " --routines " + "DATABASE_NAME" + " -B> " + filePath);
}
else if (type == "Restore")
{
textWriter.WriteLine("mysql -h " + "SERVERNAME" + " -u " + "USERNAME" + " -p" + "PASSWORD" +" -P " + "PORT" + " <" + filePath);
}
textWriter.Close();
Process processes = new Process();
processes.StartInfo.WorkingDirectory = directoryName ;
processes.StartInfo.FileName = "Backup.BAT";
processes.StartInfo.CreateNoWindow = true;
processes.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processes.Start();
processes.WaitForExit();
Lines:
change to: