【问题标题】:Can't find Json file inside project在项目中找不到 Json 文件
【发布时间】:2015-03-05 12:07:27
【问题描述】:

我正在尝试从我的项目中读取一个 json 文件,但 vs 找不到它。当我使用.txt 扩展名时,一切正常,但是当我将扩展名更改为.json 时,则找不到文件

string fileContent;
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///Resources/Database/text.json"));
using (StreamReader sRead = new StreamReader(await file.OpenStreamForReadAsync()))
fileContent = await sRead.ReadToEndAsync();

“系统找不到指定的文件。(来自 HRESULT 的异常: 0x80070002)"

【问题讨论】:

    标签: c# json file windows-phone-8 readfile


    【解决方案1】:

    若要使用 JSON 文件,您需要在 Visual Studio 的文件资源管理器中右键单击该文件并选择“属性”,然后在“高级”部分:

    1) 将Build Action 设置为Content

    2) 将Copy to Output Directory 设置为Copy always

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-31
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      • 2021-01-19
      • 2020-06-08
      • 2013-01-31
      • 1970-01-01
      相关资源
      最近更新 更多