yasirkula / UnitySimpleFileBrowser

A uGUI based runtime file browser for Unity 3D (draggable and resizable)
MIT License
874 stars 113 forks source link

Access Denied when using folder ? #59

Closed PlantDad closed 2 years ago

PlantDad commented 2 years ago

Hey. This is a fantastic plugin. Thanks a lot for making it.

I've been trying to get this to work all day. I get an access error every time i try to load a folder. Apologies in advance, it's probably super simple.

When I use

This method: yield return FileBrowser.WaitForLoadDialog( FileBrowser.PickMode.FilesAndFolders, true, null, null, "Load Files and Folders", "Load" );

I get the following error when opening a folder:

UnauthorizedAccessException: Access to the path 'and insert path here' is denied;

I've tried using the folders only option, but it yields the same result.

I then tried using your other method

FileBrowser.ShowLoadDialog( ( paths ) => { Debug.Log( "Selected: " + paths[0] ); },
                                   () => { Debug.Log( "Canceled" ); },
                                   FileBrowser.PickMode.Folders, false, null, null, "Select Folder", "Select" );

But my issue here is that I can't figure out how to read paths[0] afterwards. I tried using OnSuccess but I have no idea how to get the value out of that either.

Hope you can help. An example would be great. Thanks in advance.

yasirkula commented 2 years ago

Do you mean you double click a folder in the file browser and it always throws UnauthorizedAccessException and doesn't list the files in that folder? Could you give any more info that might be useful like the target platform?

PlantDad commented 2 years ago

Hey. I'm selecting a folder and not a file, because I need the path of the folder. When i click load, It then throws the UnauthorizedAccessException. Buildplatform for now is just windows x64_86.

I read somewhere that it might be trying to read the folder as a file, but I figured there had to be more to it in this case since the file browser is supposed to be able to read both.

PlantDad commented 2 years ago

I realized what the problem was after reading your reply and answering. I was working from your example and I hadn't removed the line where it reads the first few bytes of the file, of course that would throw an exception, because the file didn't exist. The access denied exception threw me off, along with that I didn't get a printout from earlier in the script than the error occurred. After commenting the line out it works perfectly. Been trying a ton of other things but it's always something simple. Thanks for the help.

yasirkula commented 2 years ago

BTW when you use ShowLoadDialog, the answer to "I can't figure out how to read paths[0] afterwards" is, you process the path inside ( paths ) => { Debug.Log( "Selected: " + paths[0] ); }.

PlantDad commented 2 years ago

Ah Yeah. I can see it now. I thought it was closed off. Thanks !