How to access a file from the android project in Xamarin

Tobi-Wan-KenobiTobi-Wan-Kenobi DKMember
edited November 5 in Xamarin.Android

I have two files in my android project in Xamarin which I would like to access and turn into a byte array. Something like:
byte[] fileInBytes = File.ReadAllBytes(Path.Combine("Models", "myFile.dat"));

But I haven't been able to access them with the methods I've tried so far. I've tried accessing them by using assembly.GetName().Name + "." + "Models.myFile.dat") but with no luck. I found a lot of examples on how to read from a file in the Assets folder, but I don't need to read, I need the file as bytes.

At the moment the files build action is set to "Embedded Resource", but I don't know if that is correct. Please help.

I've attached a picture that shows where the files are placed.

Best Answer

Answers

Sign In or Register to comment.