Ierdna100 / OSLoader

Mod loader for Obenseuer based on Unity Doorstop
2 stars 0 forks source link

Unnecessary File.Create has high risk in throwing "IOException: sharing violation..." #1

Closed BoettcherDasOriginal closed 4 months ago

BoettcherDasOriginal commented 4 months ago

Bug/Error

// LoaderConfig.cs
// Line 41-46

Directory.CreateDirectory(Path.Combine(loaderFilepath, configFilepath));
File.Create(Path.Combine(loaderFilepath, configFilepath, loaderConfigFileFilepath));
configRef = new LoaderConfig();
File.WriteAllText(Path.Combine(loaderFilepath, configFilepath, loaderConfigFileFilepath), JsonConvert.SerializeObject(configRef, Formatting.Indented));

Loader.Instance.logger.logDetails = configRef.logDetails;

File.Create() on Line 42 opens an file stream (Does not directly close it!) File.WriteAllText() on Line 44 trys to open an file stream too -> IOException: sharing violation

Solution:

Remove File.Create() on Line 42 cuz File.WriteAllText() creates a new file automatically