Quantcast
Viewing all articles
Browse latest Browse all 204402

How to delete files using xamarin forms

I tried to delete file from specific directory(Folder) but it doesn't work for me

I used this sample but doesn't work

https://forums.xamarin.com/discussion/123031/deleting-the-media-file-from-storage

this is my code

  DeletePhoto.Clicked += async (sender, args) =>
            {
                var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,

                });


                if ( file != null)
                {
                    if (File.Exists(file.Path))
                    {
                        DependencyService.Get<IFileManager>().DeleteFile(file.Path);
                    }
                    file.Dispose();

                }
            };

In android

        public class FileManager : IFileManager
            {
                public void DeleteFile(string source)
                {
                    File.Delete(source);
                }
            }

In mainfest permisson is given but something didn't happen and i find the file which i deleted


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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