MySqlBackupNET/MySqlBackup.Net

Directory not found when creating a backup

MihailsKuzmins opened this issue · 4 comments

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?

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);
}

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 😶

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

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/