Skip to content

Commit

Permalink
[bot] AutoMerging: merge all upstream's changes:
Browse files Browse the repository at this point in the history
* https://github.com/leiurayer/downkyi:
  修复程序反复读取设置文件的问题
  • Loading branch information
github-actions[bot] committed Jul 27, 2023
2 parents ad8e4ea + 3331737 commit b4221e7
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/DownKyi.Core/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,23 @@ private SettingsManager()
/// <returns></returns>
private AppSettings GetSettings()
{
if (appSettings != null) { return appSettings; }

try
{
FileStream fileStream = new FileStream(settingsName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
string jsonWordTemplate = streamReader.ReadToEnd();
streamReader.Close();
fileStream.Close();
//FileStream fileStream = new FileStream(settingsName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//StreamReader streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
//string jsonWordTemplate = streamReader.ReadToEnd();
//streamReader.Close();
//fileStream.Close();
string jsonWordTemplate = string.Empty;
using (var stream = new FileStream(settingsName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
{
using (var reader = new StreamReader(stream, System.Text.Encoding.UTF8))
{
jsonWordTemplate = reader.ReadToEnd();
}
}

#if DEBUG
#else
Expand Down

0 comments on commit b4221e7

Please sign in to comment.