diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs index 57662ba..9994646 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherAccountParser.cs @@ -145,7 +145,7 @@ public bool RemoveAccount(Guid id) var result = Find(id); if (!result.HasValue) return false; - var (key, value) = result.Value; + var (key, _) = result.Value; LauncherAccount?.Accounts?.Remove(key); Save(); @@ -155,13 +155,21 @@ public bool RemoveAccount(Guid id) public void Save() { - if (File.Exists(_fullLauncherAccountPath)) - File.Delete(_fullLauncherAccountPath); - var launcherProfileJson = JsonSerializer.Serialize(LauncherAccount, typeof(LauncherAccountModel), new LauncherAccountModelContext(JsonHelper.CamelCasePropertyNamesSettings())); - File.WriteAllText(_fullLauncherAccountPath, launcherProfileJson); + for (var i = 0; i < 3; i++) + { + try + { + File.WriteAllText(_fullLauncherAccountPath, launcherProfileJson); + break; + } + catch (IOException) + { + if (i == 2) throw; + } + } } } \ No newline at end of file diff --git a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs index 6882ca7..2ccdf4f 100644 --- a/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs +++ b/ProjBobcat/ProjBobcat/DefaultComponent/Launch/DefaultLauncherProfileParser.cs @@ -120,14 +120,22 @@ public void RemoveGameProfile(string name) public void SaveProfile() { - if (File.Exists(_fullLauncherProfilePath)) - File.Delete(_fullLauncherProfilePath); - var launcherProfileJson = JsonSerializer.Serialize(LauncherProfile, typeof(LauncherProfileModel), new LauncherProfileModelContext(JsonHelper.CamelCasePropertyNamesSettings())); - File.WriteAllText(_fullLauncherProfilePath, launcherProfileJson); + for (var i = 0; i < 3; i++) + { + try + { + File.WriteAllText(_fullLauncherProfilePath, launcherProfileJson); + break; + } + catch (IOException) + { + if (i == 2) throw; + } + } } public void SelectGameProfile(string name) diff --git a/ProjBobcat/ProjBobcat/ProjBobcat.csproj b/ProjBobcat/ProjBobcat/ProjBobcat.csproj index 3e601be..7b8ec3d 100644 --- a/ProjBobcat/ProjBobcat/ProjBobcat.csproj +++ b/ProjBobcat/ProjBobcat/ProjBobcat.csproj @@ -66,7 +66,7 @@ resolved the issue that LaunchWrapper may not return the correct exit code - 0.35.0 + 0.36.0