我跟隨微軟的例子如何訪問使用文件夾選擇器選擇的文件夾。做完這些之後,我想要獲取所選頂層文件夾中所有子文件夾的路徑。但是我沒有得到任何結果。StorageFolder沒有得到任何數據與獲取文件夾async
代碼:
var folderPicker = new Windows.Storage.Pickers.FolderPicker();
folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
folderPicker.FileTypeFilter.Add("*");
folderPicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();
if (folder != null)
{
Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace("GameFilesToken", folder);
System.Diagnostics.Debug.WriteLine(folder.Path);
await FileManagementHelper.getFolders(folder.Path);
}
public static async Task<Queue<string>> getFolders(String TopLevel)
{
var Folder = await Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.GetFolderAsync("GameFilesToken");
var queryResults = Folder.CreateFolderQuery();
var folderList = await queryResults.GetFoldersAsync();
return new Queue<string>();
}
QueryResults
讓我進入到一個文件夾,我原來使用相同的文件夾中。 FolderList
沒有給我什麼。
我明白我的問題,唯一的是我需要得到頂級的所有目錄。因此,例如,TopLevel \,TopLevel \ Folder1,TopLevel \ Folder2,TopLevel \ Folder1 \ SubFolder1 –
@BaileyMiller在這種情況下,您需要設置[FolderDepth](https://msdn.microsoft.com/en-us/庫/窗口/應用程序/ windows.storage.search.queryoptions.folderdepth.aspx)屬性爲深。詳情請看我最新的答案。 –