Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to allow Xamarin Essentials Share to overwrite?

PhunctionPhunction CAMember ✭✭✭

I am using Xamarin essentials to share out a file from my app to the iOS Files area:
await Share.RequestAsync(new ShareFileRequest
{
Title = Title,
File = new ShareFile(file),
});

This works fine, however the problem is, if there is an existing file with the same name, the popup appears, then just disappears and nothing happens.

How do I allow it to overwrite an exiting file? It won't give that option, even if it is a file originally shared from the same app.

Tagged:

Best Answer

  • PhunctionPhunction CAMember ✭✭✭
    Accepted Answer

    Oops, dumb mistake on my part, I was altering the original path so that is why the second time fails. It will actually ask if you want to overwrite. So works fine. :blush:

Answers

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    if there is an existing file with the same name, the popup appears, then just disappears and nothing happens

    How will you deal with the shared file? After sharing, will be the file be saved? Try to check if the repeat file is saved. And you could test the sharing founction using an application like photo on the phone directly to check if the result is the same.

    If this issue only occurs for the Essentials, you could report it to the product team on github.


    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

  • PhunctionPhunction CAMember ✭✭✭

    @Yelinzh said:

    if there is an existing file with the same name, the popup appears, then just disappears and nothing happens

    How will you deal with the shared file? After sharing, will be the file be saved? Try to check if the repeat file is saved. And you could test the sharing founction using an application like photo on the phone directly to check if the result is the same.

    If this issue only occurs for the Essentials, you could report it to the product team on github.


    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

    Hi, not sure what you mean by how I will deal with the file. When the pop-up normally comes up (when sharing a file), the popup asks if you want to save to files, dropbox, etc. Touch Save to Files, then then the next window lets you chose iCloud or On My iPad, it works fine if the file does not exist in the ios files area. Try it again, the second window looks like it is about to pop up but then it just disappears, no error and does not get to the second window.

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    What I mean is to use an existing application on the phone (such as a photo application) to test the sharing function. Repeat to share the image to iCloud to check if it works like Essentails.Share.

    Here is the source about the Share class, you could refer to:
    https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/Share/Share.ios.cs#L39


    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

  • PhunctionPhunction CAMember ✭✭✭
    Accepted Answer

    Oops, dumb mistake on my part, I was altering the original path so that is why the second time fails. It will actually ask if you want to overwrite. So works fine. :blush:

Sign In or Register to comment.