我们有一个 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.
文件被标记为复制为内容".文件被复制到 ..UWPinx64DebugAppxCommon.应用程序在运行时在 package.InstalledLocationCommon
The files are marked Copy As Content. The files are copied to ..UWPinx64DebugAppx<LibraryName>Common. The app finds those files at runtime in package.InstalledLocation<LibraryName>Common
UWP 类库现在是 .NET Standard 2.0 类库.在运行时,Common 文件夹现在被复制到与 Appx 文件夹 ..UWPinx64DebugCommon 相同级别的文件夹中,我无法访问.我试过了
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 ..UWPinx64DebugCommon where I cannot access. I tried
StorageFolder installedFolder = package.InstalledLocation; StorageFolder parentFolder = await installedFolder.GetParentAsync();但 parentFolder 返回 null.如何访问作为 .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?
推荐答案您无法从 InstalledLocation 获取 .Net 标准类库中的文件.要访问文件,您可以将文件标记为Embedded Resource 和Copy Always,然后公开访问文件流的方法.
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 类库访问内容
发布评论