How to Delete Files and Application Data Container Values in One Go?

你。 提交于 2019-12-04 01:50:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!