1

I need to get the actual path of a picked image using CrossMedia library .

When I tryd to get the file path using File.Path I get a temporary path not the actual path.

It also copies the image and gives the image a new name and gives me the path of the copied image with its new name but I need the actual path.

For example
the actual path is : /storage/data/image.jpg
but it returns : /storage/data/image_1.jpg

Here is the code I am using to pick the image :

await CrossMedia.Current.Initialize();
try
{
    var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
    {
        PhotoSize = PhotoSize.Medium
    });
    if (file == null) return;
    Stream stream = null;
    stream = file.GetStream();
    string file_path = file.Path;
}
catch (Exception ex)
{
    string test = ex.Message;
}
CSDev
  • 3,177
  • 6
  • 19
  • 37
maria nabil
  • 141
  • 3
  • 9
  • 2
    if you're picking an image from the device photo gallery, I don't know that there is a canonical path you can rely on. I don't believe iOS exposes a direct file path to images stored in the image gallery - if it did then you could just harvest every image in their camera roll without permission. – Jason Jul 30 '19 at 02:19
  • Do you have duplicated image? if the name of the file is a duplicate then a number will be appended to the end https://github.com/jamesmontemagno/MediaPlugin#directories-and-file-names – Leon Jul 30 '19 at 14:58

0 Answers0