How can I get the full path of a captured picture in .NET MAUI for Mac Catalyst platform?

717 views Asked by At

I’m trying to implement a function to capture and attach a picture in .NET MAUI. It seems to be correctly working on all platforms but MAC Catalyst. The issue seems to be the FullPath property of the FileResult (Microsoft.Maui.Storage) object returned by MediaPicker.Default.CapturePhotoAsync(). While on Android I can get the entire virtual path (filename included), MAC Catalyst just returns a file with this pattern [guid].png with no path at all.

After I capture the picture I use FileInfo.CopyTo in order to copy my picked picture into a cache folder that is under my control. Everything on Android works like a charm, while on MAC Catalyst, since I do not have any correct path, copying the file throws an exception.

How can I get the right path in this platform?

1

There are 1 answers

1
Jason On BEST ANSWER

from the docs

The FullPath property doesn't always return the physical path to the file. To get the file, use the OpenReadAsync method.