Forum Xamarin Xamarin.Forms

How to access Files from Platform Specific Folders in Xamarin.Forms?

BIGPIZZA95BIGPIZZA95 Member ✭✭

Hey,
I want to access a File in Xamarin.Forms which is located in the Resources folder of my Xamarin.Android / Xamarin.iOS. Is this even possible?
The other way round isn't a possibility because the files on the platform specific parts get referenced via javascript (needed for augmented reality functions).

Tagged:

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited April 7

    I want to access a File in Xamarin.Forms which is located in the Resources folder of my Xamarin.Android / Xamarin.iOS. Is this even possible?

    We cannot access the platform files directly in Xamarin.Forms. Xamarin.Forms provides DependencyService which could help to invoke native platform functionality from shared code. Try to access the file on the platform project, then call the method in Xamarin.Forms using DependencyService.

    Related tutorial:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction

Sign In or Register to comment.