コード例 #1
0
        public async Task <string?> ShowFolderDialogAsync(OpenFolderDialog dialog, Window parent)
        {
            var filePicker = parent.StorageProvider;

            if (!filePicker.CanPickFolder)
            {
                return(null);
            }

            var options = dialog.ToFolderPickerOpenOptions();

            var folders = await filePicker.OpenFolderPickerAsync(options);

            return(folders
                   .Select(f => f.TryGetUri(out var uri) ? uri.LocalPath : null)
                   .FirstOrDefault(u => u is not null));
        }