0

My app stores some apps in the Documents folder. The user can see these files by opening the the built-in iOS app called "Files" and selecting "on my iPhone" and the name of my app. Now I'd like to open the "Files" app programmatically. This will save the user the steps of going to the home screen, tapping the "Files" icon and navigating to my folder.

I found this question Open iOS 11 Files app via URL Scheme or some other way that seems to do exactly what I want, but it is in Swift and I was not able to translate this to C# myself.

What is the C# way of the same thing as in the above question?

George
  • 2,436
  • 4
  • 15
  • 30

1 Answers1

3

you can open the Files app with the scheme shareddocuments

var url = new NSUrl("shareddocuments://" + Uri.EscapeDataString(folderPath));
UIApplication.SharedApplication.OpenUrl(url);
George
  • 2,436
  • 4
  • 15
  • 30
Jason
  • 86,222
  • 15
  • 131
  • 146
  • Thank you, Jason! This open the Files app, but does not navigate to my app's Documents folder. I tried including the folder path in the URL like this `var url = new NSUrl("shareddocuments:" + folderPath);` but this just causes an exception `Could not initialize an instance of the type 'Foundation.NSUrl'` – George Oct 23 '21 at 16:13
  • you need "//" between the scheme and the path – Jason Oct 23 '21 at 16:28
  • 1
    Thank you, Jason! Got this working. I updated your answer with complete C# code for the benefit of anyone that can find this question later. – George Oct 23 '21 at 17:14