修复程序反复读取设置文件的问题

pull/896/head
leiurayer 1 year ago
parent d15175f629
commit 3331737494

@ -55,13 +55,23 @@ namespace DownKyi.Core.Settings
/// <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

Loading…
Cancel
Save