How to share files to another app using Xamarin iOS?

MelodyMelody INMember ✭✭

I am using the below code to share the files to other apps using xamarin iOS. but i didnt get any response. What is the issue in my code? Is there any other option to share files to other apps using Xamarin iOS?

var fileDAta = NSUrl.FromFilename(fullFilename); UIActivityViewController activityVC = new UIActivityViewController( new NSObject[] { fileDAta }, null); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(activityVC, true, null);

Tagged:

Answers

  • Patil2421Patil2421 USMember ✭✭✭

    @Melody : Try this:

    void Share(string fileName)

    {

    var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

    var directoryname = Path.Combine(documents, "FolderName" + "/" + fileName);

    var ii = NSUrl.FromFilename(directoryname);

    var item = ii.Copy();

    var activityItems = new[] { item };

    var activityController = new UIActivityViewController(activityItems, null);

    var topController = UIApplication.SharedApplication.KeyWindow.RootViewController;

    while (topController.PresentedViewController != null)

    {

    topController = topController.PresentedViewController;

    }

    topController.PresentViewController(activityController, true, () => { });

    }


Sign In or Register to comment.