【问题标题】:Cannot access Zip File located in Assets folder in Windows Runtime Apps无法访问位于 Windows 运行时应用程序中资产文件夹中的 Zip 文件
【发布时间】:2016-08-28 20:52:35
【问题描述】:

我正在尝试使用以下代码获取位于解决方案资源管理器的 Assets 文件夹中的 zip 文件。它适用于其他类型的文件,例如:.txt、.jpg、.png。但是在尝试获取 zip 文件时会出错。 The system cannot find the file specified.

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

【问题讨论】:

  • 在代码中访问 Assets 文件夹会有点困难,可能是应用程序安全模型。将文件标记为内容,如果有帮助,请尝试使用此代码:var zipFile = StorageFile.GetFileFromApplicationUriAsync(new System.Uri(@"Assets\\Test.zip", System.UriKind.Relative));
  • 我试过了,但没有用。现在我得到了下面的解决方案。非常感谢@Kiran

标签: c# windows windows-runtime win-universal-app windows-8.1


【解决方案1】:

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

在从 Visual Studio 部署后,您可以通过查看(默认情况下)\bin\x86\Release\AppX\Assets 目录(或您使用的任何架构和配置)来确认该文件是否已复制到 Appx部署)。

【讨论】:

  • 哇。这是救命的。非常感谢@Rob。
猜你喜欢
  • 1970-01-01
  • 2015-03-13
  • 1970-01-01
  • 2018-11-20
  • 2012-10-06
  • 2013-08-21
  • 2017-12-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多