diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 4e4b72216..adb68de53 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -832,7 +832,7 @@ namespace ArchiSteamFarm { Directory.CreateDirectory(targetBackupDirectory); string targetBackupFile = Path.Combine(targetBackupDirectory, fileName); - File.Move(file, targetBackupFile, true); + RuntimeCompatibility.File.Move(file, targetBackupFile, true); } // We can now get rid of directories that are empty @@ -849,7 +849,7 @@ namespace ArchiSteamFarm { if (File.Exists(file)) { // This is possible only with files that we decided to leave in place during our backup function string targetBackupFile = file + ".bak"; - File.Move(file, targetBackupFile, true); + RuntimeCompatibility.File.Move(file, targetBackupFile, true); } // Check if this file requires its own folder diff --git a/ArchiSteamFarm/RuntimeCompatibility.cs b/ArchiSteamFarm/RuntimeCompatibility.cs index ae8e7a0e8..c28c112df 100644 --- a/ArchiSteamFarm/RuntimeCompatibility.cs +++ b/ArchiSteamFarm/RuntimeCompatibility.cs @@ -64,6 +64,20 @@ namespace ArchiSteamFarm { await System.IO.File.AppendAllTextAsync(path, contents).ConfigureAwait(false); #endif +#pragma warning disable IDE0022 + public static void Move([NotNull] string sourceFileName, [NotNull] string destFileName, bool overwrite) { +#if NETFRAMEWORK + if (System.IO.File.Exists(destFileName)) { + System.IO.File.Delete(destFileName); + } + + System.IO.File.Move(sourceFileName, destFileName); +#else + System.IO.File.Move(sourceFileName, destFileName, overwrite); +#endif + } +#pragma warning restore IDE0022 + [ItemNotNull] public static async Task ReadAllBytesAsync([NotNull] string path) => #if NETFRAMEWORK