Hello,
Welcome to our Microsoft Q&A platform!
Yes, you can read it by UIDocumentPickerViewController
. Add add following two keys to your Info.plist
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
Here is demo code. I picker the text file, then return the text file's NSUrl
public partial class ViewController : UIViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
UIButton button = new UIButton() {
Frame = new CoreGraphics.CGRect(10, 100, 200, 80),
BackgroundColor = UIColor.LightGray,
};
button.SetTitle("Click", UIControlState.Normal);
button.TouchUpInside += Button_TouchUpInside;
View.AddSubview(button);
// Perform any additional setup after loading the view, typically from a nib.
}
private void Button_TouchUpInside(object sender, EventArgs e)
{
string[] strs = {"public.image","public.text", };
//NSArray arr = NSArray.FromStrings(strs);
UIDocumentPickerViewController controller = new UIDocumentPickerViewController(strs,UIDocumentPickerMode.Open);
controller.Delegate = new PickerClass();
UIApplication.SharedApplication.Windows[0].RootViewController.PresentViewController(controller,true,null);
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
}
public class PickerClass : UIDocumentPickerDelegate, IUIDocumentInteractionControllerDelegate
{
public override void DidPickDocument(UIDocumentPickerViewController controller, NSUrl url)
{
var path = url.AbsoluteString;
}
}
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
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.