在通用Windows平台中找不到文件异常 [英] File Not Found Exception in Universal Windows Platform

查看:121
本文介绍了在通用Windows平台中找不到文件异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

问题是此异常:mscorlib.ni.dll中发生了System.IO.FileNotFoundException。



Visual Studio告诉我,该文件位于Assets文件夹内,并且该文件正常,因为它可以正常打开(这是非常短的json文件)。




Plase, help me, I have the following line of code in C# inside some async method and I use Universal Windows Platform (Windows 10 SDK 10.0.14393):

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

The problem is this exception: System.IO.FileNotFoundException occurred in mscorlib.ni.dll.

Visual Studio shows me, that the file is inside the Assets folder and the file is ok, because it opens normally (it is very short json file). What can be the problem or what is solution for this problem?

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

解决方案

Change the BuildAction to Content and Copy to Output Directory from Do not copy to Awayls.

这篇关于在通用Windows平台中找不到文件异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆