我正在处理一个项目,其中值存储在文本文件中,并且每次应用程序启动时都应该检索。文本文件非常简单直接:{ "HowManyDayImages": "11", "HowManyNightImages": "5",}我有这个简单的类,有两个值作为数字:public class ImageConfig{ public int HowManyDayImages { get; set; } public int HowManyNightImages { get; set; }}然后我有这个代码来查找受尊重的文件并从中读取值并设置它们:public static async void LoadConfigAsync(){ try { ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; string themeName = (string)settings.Values["Theme"]; StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFolder timeFolder = await localFolder.GetFolderAsync("Dynamic"); StorageFolder themeFolder = await localFolder.GetFolderAsync(themeName); string imageConf; if (File.Exists("images.conf")) { imageConf = File.ReadAllText("images.conf"); } else { imageConf = Encoding.UTF8.GetString(Properties.Resources.imageConf); } imageSettings = JsonConvert.DeserializeObject<ImageConfig>(imageConf); } catch { }}有了这个,我面临两个问题。第一个是在这一行“Encoding.UTF8.GetString(Properties.Resources.imageConf);” 我收到当前上下文中不存在“属性”的错误。我面临的第二个问题是我不断收到错误消息,说找不到“动态”。
1 回答
- 1 回答
- 0 关注
- 134 浏览
添加回答
举报
0/150
提交
取消