我们有一个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类库中的内容
发布评论