-
-
Save jfversluis/cb78543caa8a9b3dd0030d674e9666fa to your computer and use it in GitHub Desktop.
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
using WindowsFolderPicker = Windows.Storage.Pickers.FolderPicker; | |
namespace MauiFolderPickerSample.Platforms.Windows | |
{ | |
public class FolderPicker : IFolderPicker | |
{ | |
public async Task<string> PickFolder() | |
{ | |
var folderPicker = new WindowsFolderPicker(); | |
// Get the current window's HWND by passing in the Window object | |
var hwnd = ((MauiWinUIWindow)App.Current.Windows[0].Handler.PlatformView).WindowHandle; | |
// Associate the HWND with the file picker | |
WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, hwnd); | |
var result = await folderPicker.PickSingleFolderAsync(); | |
return result.Path; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment