如何一次性删除文件和应用程序数据容器值?

How to Delete Files and Application Data Container Values in One Go?(如何一次性删除文件和应用程序数据容器值?)
本文介绍了如何一次性删除文件和应用程序数据容器值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用中有一个重置功能,可以将应用恢复到默认状态.在那里我需要删除我创建的四个文件并删除我在 ApplicationDataContainer 中创建的设置.这就是我删除文件的方式

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()

它连同文件一起删除了 LocalState 文件夹,我只需要删除文件而不是文件夹.

It removed the LocalState folder along with the files, I jus need to remove the files not the folder.

无论如何,我可以一次性删除 ApplicationDatacontainer 中存储的所有值吗?而不是像这样一一删除?

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");

推荐答案

如果你想从本地数据存储中删除应用程序数据,试试这个.

If you want to remove application data from its local data store, try this.

await Windows.Storage.ApplicationData.Current.ClearAsync(
     Windows.Storage.ApplicationDataLocality.Local);

这篇关于如何一次性删除文件和应用程序数据容器值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)