0
コードにエラーはありません。しかし、私がバックアップすると、ファイルのサイズは0kbまたは1kbのみです。私は何も復元しません。すべてのデータは削除されます。mySQLのバックアップと復元c#
string path;
path = "D:\\MySqlBackup"+ ".sql";
StreamWriter file = new StreamWriter(path);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName ="C:\\xampp\\mysql\\bin\\mysqldump.exe";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "--user=root --password=database --database=hotelreservationandbillingsystem < D:\\MySqlBackup.sql";
psi.UseShellExecute = false;
Process process = Process.Start(psi);
string output;
output = process.StandardOutput.ReadToEnd();
file.WriteLine(output);
process.WaitForExit();
file.Close();
process.Close();
MessageBox.Show("Back Up Successfully!","Saved",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
コード復元:バックコードアップ
string path;
path = "D:\\MySqlBackup.sql";
StreamReader file = new StreamReader(path);
string input = file.ReadToEnd();
file.Close();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "C:\\xampp\\mysql\\bin\\mysqldump.exe";
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = false;
psi.Arguments = "--user=root --password=database --database=hotelreservationandbillingsystem < D:\\MySqlBackup.sql";
psi.UseShellExecute = false;
Process process = Process.Start(psi);
process.StandardInput.WriteLine(input);
process.StandardInput.Close();
process.WaitForExit();
process.Close();
MessageBox.Show("Restored Successfully!", "Restored", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
を復元しているのですか? MySqlBackupのために? – Frank
はい、前提条件が必要です MySqlBackup.NETは、以下のコンポーネントを使用して動作します。 MySQLのドットネットConnector/Net(MySql.Data.DLL) MySqlBackup.NETを動作させるには、このDLLの参照をプロジェクトに追加する必要があります。 MySql.Data.DLLは、Oracle Corporationによって開発され、GPLライセンス(http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)でライセンスされています。 –