如何从UWP访问Net Standard 2.0类库中的内容

编程入门 行业动态 更新时间:2024-10-25 10:23:22
本文介绍了如何从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类库中的内容

本文发布于:2023-11-17 05:49:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类库   内容   Net   UWP   Standard

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!