Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Deleting the Media file from storage

$
0
0

Hi,
I have been using the Media Plugin to capture the photo from android device using XF. I have noticed that the files are stored in specified directory. My question is that how can I delete these files from the storage after usage how can I do that.

I tried to delete the file after showing but the files are still in "samples" directory.

         var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions()
                                {
                                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
                                    CompressionQuality = 92,
                                    AllowCropping = true,
                                    SaveToAlbum = true,                        
                                    Directory = "Samples",
                                    Name = (Guid.NewGuid().ToString("N") + ".jpg")  
                               });


                                if (photo != null)
                                {
                                    imgPhoto.Source = ImageSource.FromStream(() => { return photo.GetStream(); });
                                                          if (File.Exists(photo.Path))
                                                {
                                                    File.Delete(photo.Path);

                                                }
                                     photo.Dispose();



                                }`

the File.Delete(photo.Path) statement executes without error however the actual file still remains in the storage.
If its not possible at this level is there a way to delete all files in specific directory on launch or close of the application? How can I access the Folder path?

Thanks in advance


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>