我有閱讀JSON文件的問題。將文件插入到解決方案資源管理器中,將「生成操作」設置爲「內容」並將屬性複製到「始終複製我希望這個文件應該可以從LocalFolder中的應用程序訪問。C# - 從JSON文件讀取
Stream localFolder = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync("sources.json");
string json;
using (StreamReader streamReader = new StreamReader(localFolder))
{
json = streamReader.ReadToEnd();
}
return JsonConvert.DeserializeObject<List<SourceDefinition>>(json);
它返回的錯誤是:
Error: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
你得到的錯誤是什麼? – joshmcode
錯誤:系統找不到指定的文件。 (來自HRESULT的異常:0x80070002) –
通過Visual Studio運行時或在部署應用程序後,您是否收到錯誤消息?同樣在你的應用程序中,你是否放置了該文件? –