无法访问位于 Windows Runtime Apps 的 Assets 文件夹中的 Zip 文件

Cannot access Zip File located in Assets folder in Windows Runtime Apps

我正在尝试使用以下代码获取位于 Solution Explorer 的 Assets 文件夹内的 zip 文件。它适用于其他类型的文件,例如:.txt、.jpg、.png。但是在尝试获取 zip 文件时会出错。 The system cannot find the file specified.

var zipFile = await Package.Current.InstalledLocation.GetFileAsync("Assets\Test.zip");

Zip 文件默认不包含在 appx 包中(.txt、.jpg 和 .png 包含)。 Select 您在解决方案资源管理器中的文件,查看 zip 文件的属性,并确保构建操作设置为 "Content" 以便该文件将包含在 Appx 中:

您可以通过查看(默认情况下)\bin\x86\Release\AppX\Assets 目录(或您选择的任何体系结构和配置)来确认文件在从 Visual Studio 部署后已(或未)复制到 Appx已部署)。