简体   繁体   中英

Unity UWP FolderPicker Throws Invalid Window Handle Exception

I'm getting the above exception when trying to user the FolderPicker in a UWP Unity App. I have copied the code from a working example but having no success:

FolderPicker folderPicker = new FolderPicker();
folderPicker.SuggestedStartLocation = PickerLocationId.Desktop;
folderPicker.FileTypeFilter.Add("*");
try
{
    StorageFolder folder = folderPicker.PickSingleFolderAsync().GetResults();
}
catch (Exception e)
{
    Debug.Log(e.ToString());
}

My assumption is that it doesn't work with Unity UWP, in a similar vein to Unity offering a subset of .NET etc. Can anyone confirm this or am I missing something obvious?

Best, Peter

Have you added the capabilities and declarations needed for accessing the files from a folder? This may be the reason for the above error.

To pick files from folder you need to select Pictures Library from Capabilities. Also under declarations add File Open Picker.

You can find this options in Package.appxmanifest.

Check this for accessing the file from the folder.

https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM