Skip to content

Commit

Permalink
Ensure settings file is completely overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgDangl committed Apr 4, 2024
1 parent 5754880 commit 041c7aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/IPA.Bcfier/Services/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ public async Task<Settings> LoadSettingsAsync()
public async Task SaveSettingsAsync(Settings settings)
{
var serializedSettings = JsonConvert.SerializeObject(settings);
using var settingsFileStream = File.OpenWrite(GetPathToSettingsFile());
var settingsFilePath = GetPathToSettingsFile();
if (File.Exists(settingsFilePath))
{
File.Delete(settingsFilePath);
}

using var settingsFileStream = File.Create(settingsFilePath);
using var streamWriter = new StreamWriter(settingsFileStream);
await streamWriter.WriteAsync(serializedSettings);
}
Expand Down

0 comments on commit 041c7aa

Please sign in to comment.