The process cannot access the file 'Bkp_20181101.sql' because it is being used by another process in MysqlBackup

116 views Asked by At

I'm tried to get mysql backup using mysqlbackup dll. The file is created but sql is not backup, above issue is throw in bkp.ExportToFile code. I'm using following query and Please help this issue, Thanks in advance.!

try{

string connectionString = $"server={ serverName };user={ userName };password={ password };persistsecurityinfo=True;database={ databaseName };SslMode=none;Convert Zero Datetime=true;";

using (con= new MySqlConnection(connString))
{
    filename = "Bkp_20181101.sql";

    using (MySqlCommand command = new MySqlCommand())
    {
        command.Connection = connection;
        OpenConnection();

        using (MySqlBackup bkp = new MySqlBackup(command))
        {
            try
            {
                bkp.ExportToFile( "D:\\" + filename);
            }
            catch (MySqlException ex)
            {
                CloseConnection();
                throw ex;
            }
        }
        CloseConnection();
    }
}
0

There are 0 answers