I am trying to get the filename from the gallery but the library I am using doesn't seem to have the method to retrieve the file name but it has the method for retrieving the file path, I am using the Xam.Plugin.Media. I need the filename to pass it as an argument in the other method I am using. Here is my code:
var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new
Plugin.Media.Abstractions.PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
});
if (file == null) return;
imgChoosed.Source = ImageSource.FromStream(() => {
var stream = file.GetStream();
return stream;
});
// computerVision = new ComputerVisionViewModel();
//I need to pass the file name as an argument here
// var result = await computerVision.ConnectToVisualRecognition(file.Path,file.Name);
use this.
var fileNameWithExtenstion = Path.GetFileName(filePath);
var fileNameWithoutExtenstion = Path.GetFileNameWithoutExtension(filePath);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.