public static void DoBackup() { CreateDirectory(); string filePath = @"C:\CST-backup\BACKUP--" + DateTime.Now.ToString("yyyy--MM--dd--HH--mm--ss--tt") + ".sql"; dbConnection.EstablishConnection2(); using (MySqlCommand cmd = new MySqlCommand()) { using (MySqlBackup md = new MySqlBackup(cmd)) { cmd.Connection = dbConnection.connection; md.ExportToFile(filePath); dbConnection.connection.Close(); } } }