Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileBrowserHelpers.GetEntriesInDirectory() only works when called once, returns null every time after #101

Open
strangeways-dev opened this issue Sep 18, 2024 · 2 comments

Comments

@strangeways-dev
Copy link

strangeways-dev commented Sep 18, 2024

Description of the bug
FileBrowserHelpers.GetEntriesInDirectory() only works when called once unless using the same folder path used the first time, returns null every time after when using a different folder path

Reproduction steps
In code write SimpleFileBrowser.FileSystemEntry[] _filePaths = FileBrowserHelpers.GetEntriesInDirectory([PUT A VALID FOLDER PATH HERE], false);, create 2 buttons and attach the method, make sure you have set a valid folder path for each method, after this method Debug.Log(_filePaths);, build and run as a UWP (Universal Windows Pacakge) then press the button which calls the method then press the other, it will only work the first time and throw errors every time after except for the method with the path which was called first otherwise it returns null.

Platform specs

  • Unity version: Tested on 2022.3.47f1 & 6000.0.16f1
  • Platform: Windows 11
  • How did you download the plugin: updated version from GitHub (Here)
@strangeways-dev
Copy link
Author

strangeways-dev commented Sep 18, 2024

I've narrowed it down to 'System.IO.Directory.Getfiles' which is saying access denied in the UWP debug console.
Directory.GetFiles is called inside of SimpleFileBrowser.FileBrowserHelpers.GetEntriesInDirectory, but is inside of a try/catch, so when the access is denied the code carries until the end and with no results it returns null.

Ultimately I believe System.IO.Directory.Getfiles is the cultpate but I can't understand why it's only working for the first path, and the first path can be anything and it will work so it's not that the other path is invalid or is unaccessible because if I use the second path first it's the same, only the first used path will work with Directory.GetFiles and every time it's used with another after/other than the first path it fails.

@yasirkula
Copy link
Owner

UWP isn't actually supported (mentioned in the asset description) because it doesn't grant access to filesystem (or am I remembering it wrong)? You may have access to persistentDataPath but I wouldn't expect access to Documents, Desktop, C:\ or other volumes. The issue shouldn't be related to this plugin since it uses System.IO APIs on UWP as you've observed. If I'm correct, replacing FileBrowserHelpers.GetEntriesInDirectory with Directory.GetFiles should result in the same behaviour. It may also give an exception describing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants