简体   繁体   English

如何在 C# xamarin forms android 中保存具有特定名称的照片?

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

相关问题 如何在 Xamarin.forms C# 中相对于图像的特定位置放置标签? - How can I place labels at specific positions relative to an image in Xamarin.forms C#? 如何在不关闭 C# xamarin forms android 的应用程序的情况下关闭侧边栏? - How could I close my sidebar without closing my app in C# xamarin forms android? How do I start a page with a function always in C# xamarin forms android? - How do I start a page with a function always in C# xamarin forms android? 如何使用 C# xamarin forms android 中的 ImageButton 水平移动? - how to move horizontally using ImageButton in C# xamarin forms android? 如何清除 C# xamarin forms android 中的 MultipartFormDataContent? - How to clear a MultipartFormDataContent in C# xamarin forms android? 如何以 xamarin 形式将列表保存到 sqlite 数据库中 - how can i save a list into sqlite database in xamarin forms 我如何以Xamarin形式在sqlite中保存对象列表 - How can i save a list of object in sqlite in xamarin forms 如何获取 C# xamarin forms android 中的活动图像的来源? - How to get the source of the Active image in C# xamarin forms android? 使用C#和Xamarin表单-如何在不设置闭包链的情况下关闭一个模式 - Using C# & Xamarin Forms - How can I close one modal without setting of chain of closures 如何使用 c# 在 xamarin.forms 登录成功后更改内容 - How can i change content after login success in xamarin.forms using c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM