我不断收到输出到Debug.Window。我试图通过“appFolder.GetFilesAsync();”尝试读取文件列表时出现错误
Der Thread 0xd88 hat mit Code 0 (0x0) geendet.
Der Thread 0x6fc hat mit Code 0 (0x0) geendet.
Der Thread 0xce8 hat mit Code 0 (0x0) geendet.
Der Thread 0x68c hat mit Code 0 (0x0) geendet.
我的代码是:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.UI.Xaml.Controls;
namespace WindowsIOTControlCenter.ImageRotation
{
class ImageRotation
{
Timer _time;
IReadOnlyList<StorageFile> pictures;
public ImageRotation(Grid targetGrid)
{
pictures = scanImagesFolder().Result;
}
private async Task<IReadOnlyList<StorageFile>> scanImagesFolder()
{
try
{
StorageFolder appFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("ImageRotation\\BackgroundImages");
IReadOnlyList<StorageFile> filesInFolder = await appFolder.GetFilesAsync();
foreach (StorageFile file in filesInFolder)
Debug.WriteLine(file.Name + ", " + file.DateCreated);
return null;
}
catch(Exception ex)
{
Debug.WriteLine(ex.Message);
return null;
}
}
}
}
我用了一个非常简单的例子,从INET,因为我原来的代码有我现在有这个例子同样的问题。
我基本上想要一个位于指定目录中的文件列表。
分步调试显示将目录分配给appFolder没有问题。
但是,当涉及到
IReadOnlyList<StorageFile> filesInFolder = await appFolder.GetFilesAsync();
上述输出滴出一步步骤。显然没有例外可以捕捉,否则它会继续捕捉(Exception ex)。
有没有人知道我做错了什么,或者可以指出我的问题的另一种解决方案?
任何提示是apreciated。
P.S .:对不起,我糟糕的英语。