繁体   English   中英

如何从从图库中挑选的图像中获取文件名?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM