问题描述
我正在尝试使用以下代码获取位于解决方案资源管理器的 Assets 文件夹内的 zip 文件.它适用于其他类型的文件,如:.txt、.jpg、.png.但是在尝试获取 zip 文件时会出错.系统找不到指定的文件.
I'm trying to get the zip file that is located inside the Assets folder of Solution Explorer with the following code. It works well for other types of file like: .txt, .jpg, .png. But it gives error when trying to get the zip file. The system cannot find the file specified.
var zipFile = await Package.Current.InstalledLocation.GetFileAsync("Assets\\Test.zip");
推荐答案
Zip 文件默认不包含在 appx 包中(.txt、.jpg 和 .png 包含).在解决方案资源管理器中选择您的文件,查看 zip 文件的属性,并确保将构建操作设置为内容",以便该文件将包含在 Appx 中:
Zip files aren't included in the appx package by default (.txt, .jpg, and .png are). Select your file in the solution explorer, look at the zip file's properties, and make sure the build action is set to "Content" so that the file will be included in the Appx:
通过查看(默认情况下)\bin\x86\Release\AppX\Assets 目录(或任何架构和配置),您可以确认从 Visual Studio 部署后文件是否已(或未)复制到 Appx部署).
You can confirm that the file was (or was not) copied to the Appx after deploying from Visual Studio by looking in the (by default) \bin\x86\Release\AppX\Assets directory (or whichever architecture and configuration you deployed).
这篇关于无法访问位于 Windows 运行时应用程序资产文件夹中的 Zip 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!