mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
If filePath not exists then use File.Move
This commit is contained in:
parent
cf61535797
commit
fc85ee45b7
1 changed files with 15 additions and 8 deletions
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue