![](/img/trans.png)
[英]How can I get the width and height of an Image picked from gallery after cropping in it Image view
[英]How can I get the file name from an image picked from the gallery?
我正在嘗試從圖庫中獲取文件名,但我正在使用的庫似乎沒有檢索文件名的方法,但它具有檢索文件路徑的方法,我使用的是 Xam.Plugin.Media。 我需要將文件名作為參數傳遞給我正在使用的其他方法。 這是我的代碼:
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);
用這個。
var fileNameWithExtenstion = Path.GetFileName(filePath);
var fileNameWithoutExtenstion = Path.GetFileNameWithoutExtension(filePath);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.