Skip to content

How to access the "Assets" folder from C# code #4685

Closed Answered by whiskhub
DJRM2021 asked this question in Q&A
Discussion options

You must be logged in to vote

If your Windows App SDK app is packaged (MSIX), then it will work with Windows.ApplicationModel.Package.Current.InstalledPath, yes.

For unpackaged apps, it will just be the folder next to your EXE. So you can use System.Reflection.Assembly.GetEntryAssembly().Location; or GetModuleFileNameW to get the EXE path, and then get the directory using Path.GetDirectoryName or similar.

Within XAML or other WinRT APIs, you can also use Uris like ms-appx:///Assets. There is also Microsoft.Windows.ApplicationModel.Resources.ResourceManager within WinAppSDK, with which you can access any Content resources with a path like Assets/MyFile.jpg.. It should also work in unpackages apps afaik.

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ghost1372
Comment options

Answer selected by DJRM2021
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants