问题
I have a reset function in my app which brings the app back to default state. There for I need to remove the four files I created and remove the settings I created in the ApplicationDataContainer
.
This is how I remove the files
try
{
StorageFile file = await localfolder.GetFileAsync("HistoryFile");
if (file != null)
{
await file.DeleteAsync();
}
}
catch
{
//Catch Process
}
Is there a function which removes all the files together? When I tried the following code
localfolder.DeleteAsync()
It removed the LocalState folder along with the files, I jus need to remove the files not the folder.
And is there anyway in which I jus can remove all the values stored in ApplicationDatacontainer in one go? rather than removing them one by one like this?
localSettings.DeleteContainer("exampleContainer");
回答1:
If you want to remove application data from its local data store, try this.
await Windows.Storage.ApplicationData.Current.ClearAsync(
Windows.Storage.ApplicationDataLocality.Local);
来源:https://stackoverflow.com/questions/16709675/how-to-delete-files-and-application-data-container-values-in-one-go