Not valid path to a photo in a gallery

I'm trying to send an SMTP mail from an app on an iphone. And I want to attach a photo from a gallary. This is how i get path to a photo:

IMediaPicker _mediaPicker = Resolver.Resolve();

private async Task SelectPicture()
{
try
{
var mediaFile = await this._mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
{
DefaultCamera = CameraDevice.Front,
MaxPixelDimension = 400
});
return mediaFile.Path;

        }
        catch (System.Exception ex)
        {
            return string.Empty;
        }
    }

the path, returned by method is like this one:
"/Users/MyName/Library/Developer/CoreSimulator/Devices/76F75CC0-CDA1-4EBB-B0DD-CEA09C2259EB/data/Containers/Data/Application/991BF89B-E3A6-4A4F-8B1F-C255862D745E/Documents/temp/IMG_20150716_125017.jpg"

The problem is that when i try to create attachment to an Email

MailMessage mail = new MailMessage();
mail.Attachments.Add(new Attachment(path));

I get an error:
{System.IO.FileNotFoundException: Could not find file "/Users/MyName/Library/Developer/CoreSimulator/Devices/76F75CC0-CDA1-4EBB-B0DD-CEA09C2259EB/data/Containers/Data/Application/F0B3933E-8A97-48F8-872D-52043466EBCD/Documents/temp/IMG_20150716_125326.jpg".
File name: '/Users/MyName/Library/Developer/CoreSimulator/Devices/76F75CC0-CDA1-4EBB-B0DD-CEA09C2259EB/data/Containers/Data/Application/F0B3933E-8A97-48F8-872D-52043466EBCD/Documents/temp/IMG_20150716_125326.jpg'
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x0022d] in /Users/builder/data/lanes/1962/8b265d64/source/mono/mcs/class/corlib/System.IO/FileStream.cs:242
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in /Users/builder/data/lanes/1962/8b265d64/source/mono/mcs/class/corlib/System.IO/FileStream.cs:97
at System.IO.File.OpenRead (System.String path) [0x00000] in /Users/builder/data/lanes/1962/8b265d64/source/mono/mcs/class/corlib/System.IO/File.cs:341
at System.Net.Mail.AttachmentBase..ctor (System.String fileName) [0x00024] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.3.2/src/mono/mcs/class/System/System.Net.Mail/AttachmentBase.cs:79
at System.Net.Mail.Attachment..ctor (System.String fileName) [0x0000b] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.3.2/src/mono/mcs/class/System/System.Net.Mail/Attachment.cs:48
at Proffinstal.iOS.CatalogIOS.SendMessageMail (System.String theme, System.String message, System.Collections.Generic.List`1 files, System.String mainAdress) [0x000f4] in d:\Evgeniy\Flow\profinstallIos\Proffinstal.IOS\Proffinstal\Proffinstal.iOS\CatalogIOS.cs:158 }

Help me please

Sign In or Register to comment.