Home > Blockchain >  Full project folder path necessary to access Assets in Xamarin Android
Full project folder path necessary to access Assets in Xamarin Android

Time:09-13

EDIT 1

In VS for Mac it actually works as intended. The described behaviour only occurs in Rider 2022.2.2 for me.

Original Question

In my Xamarin Android project I have a folder "Assets" including an asset file "certificate.crt". The build action of the file is set to AndroidAsset. To be able to access the asset with the asset manager I have to specify the full file path.

var assetManager = Android.App.Application.Context.Assets;
using (var certStream = assetManager.Open("Users/myuser/Documents/Projects/MyProject/MyProject.Android/Assets/certificate.crt"))
{
    // use the certStream
}

I found the file path by renaming the .apk to .zip and extracting the files then. So the .apk included an "Assets" folder and in there were all the folders specified above. But what I obviously want is to just pass the filename to the assets manager.

assetManager.Open("certificate.crt") 

How do I achieve that?

CodePudding user response:

So it seems to be a bug in Rider for Mac. VS for Mac works as expected.

  • Related