GetFileFromApplicationUriAsync 抛出 "The system cannot find the file specified"

GetFileFromApplicationUriAsync throws "The system cannot find the file specified"

我真的不明白为什么会出现此异常:“系统找不到指定的文件”。

请检查下面的代码。我能够获取文件 test3 但无法获取 test2。我很确定它们在同一个文件夹下。而且我也无法读取 ms-appx 路径下的其他文件,除了 Assets 文件夹下的 png 文件。

有人可以帮忙吗?这是 link to my code and this is the link to the Assets folder.

  var test3 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/folder.png"));
  var test2 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/zh.grxml"));

在项目文件中你会看到这个

<Content Include="Assets\folder.png" />
<None Include="Assets\zh.grxml" />

zh.grxml 复制到输出目录(一种或另一种方式),您将获得一致的结果

例子

<Content Include="Assets\zh.grxml" />