c# - 通用 Windows 平台中找不到文件异常

标签 c# windows exception windows-10-universal

请帮帮我,我在一些异步方法中使用 C# 编写了以下代码行,并且我使用的是通用 Windows 平台(Windows 10 SDK 10.0.14393):

var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/HamburgerMenuItems.json"));

问题是这个异常:System.IO.FileNotFoundException occurred in mscorlib.ni.dll。

Visual Studio 向我显示该文件位于 Assets 文件夹中并且文件正常,因为它可以正常打开(它是非常短的 json 文件)。可能是什么问题或者这个问题的解决方案是什么?

this image shows, that the file is inside the Assets folder

最佳答案

BuildAction 更改为 Content 并将 Copy to Output DirectoryDo not copy 更改为 Awayls

enter image description here

关于c# - 通用 Windows 平台中找不到文件异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38776253/

相关文章:

windows - 如何通过命令行启动 Windows Scheduler?

c# - 记录致命异常

ruby - 嵌套异常中的回溯

c# - WebBrowser.Print() 等到完成。 。网

c# - Windows 8 中的透明度(Metro 应用程序)

windows - 记录系统调用

c++ - 如何在不使用任何资源编辑器的情况下手动加载图标?

android - java.lang.IllegalStateException : Not allowed to start service Intent while trying to run RingtoneService 错误

c# - 资源泄漏和内存泄漏与性能之间的关系

c# - 是否可以使用 VSPackage 添加新项目向导?