如何从UWP访问Net Standard 2.0类库中的内容 [英] How to access content from a Net Standard 2.0 class libary from UWP

查看:95
本文介绍了如何从UWP访问Net Standard 2.0类库中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个UWP应用,它引用了UWP类库。 UWP类库具有一个Common文件夹,其中包含运行时所需的文件。

We have a UWP app which references a UWP class library. The UWP class library has a Common folder with files that are required at runtime.

这些文件被标记为复制为内容。将文件复制到。.\UWP\bin\x64\Debug\Appx\< LibraryName> \Common 。该应用程序在运行时以包的形式找到这些文件。InstalledLocation\< LibraryName> \Common

The files are marked Copy As Content. The files are copied to ..\UWP\bin\x64\Debug\Appx\<LibraryName>\Common. The app finds those files at runtime in package.InstalledLocation\<LibraryName>\Common

UWP类库现在是.NET Standard 2.0类库。现在,在运行时,将Common文件夹复制到与Appx文件夹相同级别的文件夹。.\UWP\bin\x64\Debug\Common 其中我无法访问。我尝试过

The UWP class library is now a .NET Standard 2.0 class library. At runtime the Common folder is now copied to a folder at the same level as the Appx folder ..\UWP\bin\x64\Debug\Common where I cannot access. I tried

StorageFolder installedFolder = package.InstalledLocation;
StorageFolder parentFolder = await installedFolder.GetParentAsync();

parentFolder 返回。如何访问.NET Standard 2.0类库中内容的文件和文件夹?

but parentFolder returns null. How do I access files and folders that are content from a .NET Standard 2.0 class library?

推荐答案

您无法获取文件在.Net标准类库中的 InstalledLocation 中。要访问文件,您可以将文件标记为嵌入式资源始终复制,然后公开一种方法来访问文件文件流。

You can not get the file in the .Net standard class library from the InstalledLocation. To access the files, you can mark the file as Embedded Resource and Copy Always, then expose a method to access the file stream.

这里是一个非常相似的线程,您可以看到实现它的详细步骤,

Here is a very similar thread, you can see the detailed steps to achieve it,

如何在ARM平台的.NET Standard 1.4库中包含资产文件?

这篇关于如何从UWP访问Net Standard 2.0类库中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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