Du kan använda MySqlBackup.NET som alternativ till MySqlDump
Dokumentation:
http://www.codeproject.com/Articles/256466/MySqlBackup-NET-MySQL-Backup-Solution-for-Csharp-V
https://github.com/MySqlBackupNET/MySqlBackup.Net
Exempelkoder:
Säkerhetskopiera en MySQL-databas
using MySql.Data.MySqlClient;
sedan koden,
private void Backup()
{
string constring = "server=localhost;user=root;pwd=qwerty;database=test;";
string file = "C:\\backup.sql";
using (MySqlConnection conn = new MySqlConnection(constring))
{
using (MySqlCommand cmd = new MySqlCommand())
{
using (MySqlBackup mb = new MySqlBackup(cmd))
{
cmd.Connection = conn;
conn.Open();
mb.ExportToFile(file);
conn.Close();
}
}
}
}
Återställ en MySQL-databas
private void Restore()
{
string constring = "server=localhost;user=root;pwd=qwerty;database=test;";
string file = "C:\\backup.sql";
using (MySqlConnection conn = new MySqlConnection(constring))
{
using (MySqlCommand cmd = new MySqlCommand())
{
using (MySqlBackup mb = new MySqlBackup(cmd))
{
cmd.Connection = conn;
conn.Open();
mb.ImportFromFile(file);
conn.Close();
}
}
}
}
Uppdatering:
Jag är en av författarna till detta bibliotek.