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.
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
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();
but parentFolder
returns null
. How do I access files and folders that are content from a .NET Standard 2.0 class library?
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,
How to include asset files in a .NET Standard 1.4 library in ARM platform?