Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a file from local disk in UWP

I am trying to delete a picture stored in my local folder in my UWP application. However, I am not very sure how to do it.

The picture file is located under "Pictures", which I think the path is:

C:\Users\UserName\Pictures

I have written a set of code which I believe is to retrieve the file... however, I am not sure how to continue from here.

StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
string name = "deletetest.jpg";
StorageFile manifestFile = await picturesFolder.GetFileAsync(name);
like image 967
thalassophile Avatar asked Jan 30 '23 06:01

thalassophile


1 Answers

Just add this lines.DeleteAsync will delete the file.

 StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
 string name = "deletetest.jpg";
 StorageFile manifestFile = await picturesFolder.GetFileAsync(name);
 await manifestFile.DeleteAsync();
like image 134
Mohanvel V Avatar answered Feb 27 '23 18:02

Mohanvel V