我已经隔离了以下代码,它在 OnNavigatedTo 事件中工作,所以我知道代码可以工作。但是,我不能在那里使用它。我需要在 Suspending 事件中使用它。但它不会在那里工作。当我设置断点时,它们不会在这个事件中的任何地方被击中。也没有编译时或运行时错误。
到底是怎么回事?
async void App_Suspending(
Object sender,
Windows.ApplicationModel.SuspendingEventArgs e)
{
IReadOnlyList<StorageFile> thefiles;
var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
thefiles = await localFolder.GetFilesAsync();
foreach (var f in thefiles)
{
await f.DeleteAsync(StorageDeleteOption.Default);
}
}