How can I load the contents of a local file into a byte array?

garrwillgarrwill Member ✭✭

I hope "local file" is even the correct term. I want to load the contents of a file in Resources/drawable in an Android app into a byte array. How?
And should it have a Build Action other than AndroidResource?

Best Answers

  • garrwillgarrwill ✭✭
    Accepted Answer

    I managed to get Xamarin.Essentials installed and working.

    Oddly, I had to change the first line in the sample code above to the following:

    Stream s = Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("myfilename").Result;

    Other than that, your answer resolved my issue. Thanks.

Answers

  • garrwillgarrwill Member ✭✭

    Sounds promising. Next question: How do I get Xamarin Essentials?

  • garrwillgarrwill Member ✭✭
    Accepted Answer

    I managed to get Xamarin.Essentials installed and working.

    Oddly, I had to change the first line in the sample code above to the following:

    Stream s = Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("myfilename").Result;

    Other than that, your answer resolved my issue. Thanks.

  • stesvisstesvis USMember ✭✭✭

    Where is "myfilename" stored in the solution?

Sign In or Register to comment.