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

UnauthorizedAccessException when gettings shortcut files #2

Open
NitroFrench opened this issue Nov 5, 2020 · 2 comments
Open

UnauthorizedAccessException when gettings shortcut files #2

NitroFrench opened this issue Nov 5, 2020 · 2 comments

Comments

@NitroFrench
Copy link

Hi, thanks for this very good looking program.

When initiazing, inStrmenu.cs there is an instruction to get all shortcut files from various path :
foreach (var shortcut in Directory.GetFiles(path, "*.lnk", SearchOption.AllDirectories))

The GetFiles throws an UnthaurizedAccessException when accessing my appdata folder.

Tried to change the appmanifest, run as admin, security settings of folder, but I found no way the fix this, any idea ?

@gerardbalaoro
Copy link
Owner

gerardbalaoro commented Nov 10, 2020

@NitroFrench I can't replicate this issue. The application should ask trigger UAC when launched which should give read access to the shortcuts folder.

Can you provide additional information?

@NitroFrench
Copy link
Author

Thanks for replying @gerardbalaoro
It does as for administrator priviledge when started, but even though I have an Unauthorized access when calling Directory.GetFiles on ProgramData folder (not on AppData/roaming...).

Google that and found many people had this issue which seems related to some subdirectories beeing readonly or protected.
The workaround is to recursively scan each subdirectory in order to catch exception and skip the subdirectories which cause the issue.

I made a PR which a fix to this problem, as I finaly found what was going on.

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