MySqlBackup.Net icon indicating copy to clipboard operation
MySqlBackup.Net copied to clipboard

Directory not found when creating a backup

Open MihailsKuzmins opened this issue 4 years ago • 4 comments
trafficstars

If a directory does not exist, an exception is thrown, therefore, I need to call Directory.CreateDirectory("my path") myself. Could you please add this code in the ExportToFile method?

MihailsKuzmins avatar Mar 21 '21 13:03 MihailsKuzmins

I think this should be handled externally. Just add the code for checking the directory before running the backup.

string folder = "C:\backup";
if (!Directory.Exists(folder))
{
    Directory.CreateDirectory(folder);
}

adriancs2 avatar Mar 22 '21 03:03 adriancs2

Directory.Exists(folder) is pointless before Directory.CreateDirectory(folder). CreateDirectory already handles it. My issue was that the code in "MySqlBackup.Net" does not handle it. There is an exception "Directory does not exist" if I don't call Directory.CreateDirectory("my path"). This is what I get If I don't call Directory.CreateDirectory() image

Sorry, I should have copied the exception in the issue description in the first place. I thought I had described the issue, but apparently failed :no_mouth:

MihailsKuzmins avatar Mar 22 '21 07:03 MihailsKuzmins

I think it is ok to add the folder creation code. It will be added in the next release. Cheers.

adriancs2 avatar Mar 22 '21 14:03 adriancs2

Hi, @MihailsKuzmins , I have already added this feature at the new release. You may check it out :)

Release: https://github.com/MySqlBackupNET/MySqlBackup.Net/releases/tag/fe2ca1f

Nuget: https://www.nuget.org/packages/MySqlBackup.NET/

adriancs2 avatar Sep 22 '21 08:09 adriancs2