How to open files on Xamarin Android?

Ronald GANS 136 Reputation points
2023-03-13T17:42:05.08+00:00

Can I do something like OpenFileDialog( ) ? I want to allow the users to look at files on their device and open them. Also to save them.

Like I normally do:

OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "File Open";
try
  {

     if (openFileDialog1.ShowDialog() == DialogResult.OK){

                }

etc.

Thanks.

RON

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 72,251 Reputation points Microsoft Vendor
    2023-03-14T02:57:47.01+00:00

    Hello,

    Can I do something like OpenFileDialog( ) ? I want to allow the users to look at files on their device and open them. Also to save them.

    Yes, if you want to do that.

    For Android 11 or later, you need to request manage_external_storage Permission in Xamarin.Android

    For android 10 or before, you can continue to set requestLegacyExternalStorage to true in your app's manifest file and request read and write external storage permission at the runtime.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.