Home > Back-end >  how can I save a photo with an specific name in C# xamarin forms android?
how can I save a photo with an specific name in C# xamarin forms android?

Time:08-20

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. by default the name is something like this "IMG_20220818_17585.jpg"

how could I save it with a diferent name?

Thank you very much!

CodePudding user response:

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:

var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
    Directory = "Sample",
    Name = "test.jpg"
});

CodePudding user response:

SOLUTION / UPDATE

this resolved my problem.

var file2 = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
            {
                Name = "Name that I want",
                SaveToAlbum = true
            });
  • Related