[英]how can I save a photo with an specific name in C# xamarin forms android?
I'm trying to put a name to an image when I save it in my folder.当我将图像保存在我的文件夹中时,我正在尝试为图像命名。
this is my code:这是我的代码:
var file2 = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
{
SaveToAlbum = true
});
this take a photo and then save it in /Pictures but I need to name it.这会拍一张照片,然后将其保存在 /Pictures 中,但我需要为其命名。 by default the name is something like this "IMG_20220818_17585.jpg"
默认情况下,名称类似于“IMG_20220818_17585.jpg”
how could I save it with a diferent name?我怎么能用不同的名字保存它?
Thank you very much!非常感谢!
According to CrossMedia 's documentation on directory and file name, I believe you only need to assign a value to the "Name" property in your StoreCameraMediaOptions:根据CrossMedia关于目录和文件名的文档,我相信您只需为 StoreCameraMediaOptions 中的“名称”属性分配一个值:
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Sample",
Name = "test.jpg"
});
SOLUTION / UPDATE解决方案/更新
this resolved my problem.这解决了我的问题。
var file2 = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
{
Name = "Name that I want",
SaveToAlbum = true
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.