If filePath not exists then use File.Move

This commit is contained in:
Jaex 2020-05-29 16:50:23 +03:00
parent cf61535797
commit fc85ee45b7

View file

@ -147,16 +147,23 @@ private bool SaveInternal(string filePath)
throw new Exception($"{typeName} file is corrupt: {tempFilePath}");
}
string backupFilePath = null;
if (CreateBackup)
if (File.Exists(filePath))
{
string fileName = Path.GetFileName(filePath);
backupFilePath = Path.Combine(BackupFolder, fileName);
Helpers.CreateDirectoryFromDirectoryPath(BackupFolder);
}
string backupFilePath = null;
File.Replace(tempFilePath, filePath, backupFilePath);
if (CreateBackup)
{
string fileName = Path.GetFileName(filePath);
backupFilePath = Path.Combine(BackupFolder, fileName);
Helpers.CreateDirectoryFromDirectoryPath(BackupFolder);
}
File.Replace(tempFilePath, filePath, backupFilePath);
}
else
{
File.Move(tempFilePath, filePath);
}
if (CreateWeeklyBackup && !string.IsNullOrEmpty(BackupFolder))
{