-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f76368f
commit ea28b8d
Showing
2 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#if __MACOS__ | ||
using System; | ||
using System.Threading.Tasks; | ||
using AppKit; | ||
using Windows.Foundation; | ||
|
||
namespace Windows.Storage.Pickers | ||
{ | ||
public partial class FolderPicker | ||
{ | ||
public FolderPicker() | ||
{ | ||
} | ||
|
||
public IAsyncOperation<StorageFolder> PickSingleFolderAsync() => | ||
PickSingleFolderImplAsync().AsAsyncOperation(); | ||
|
||
private async Task<StorageFolder> PickSingleFolderImplAsync() | ||
{ | ||
var openPanel = new NSOpenPanel(); | ||
openPanel.AllowedFileTypes = new[] { "none" }; | ||
openPanel.AllowsOtherFileTypes = false; | ||
openPanel.CanChooseDirectories = true; | ||
openPanel.CanChooseFiles = false; | ||
var response = openPanel.RunModal(); | ||
if (response == 1 && openPanel.Urls.Length > 0) | ||
{ | ||
var path = openPanel.Urls[0]?.Path; | ||
if (path != null) | ||
{ | ||
return new StorageFolder(path); | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} | ||
#endif |