+ 1
Access denied from Directory.Getfiles(path, name, Searchoption.Alldirectory)
How to solve this problem in C#? I got somethings like "Unauthorized Access denied" when i try to use Directory.getfiles(@"d:\", "*", searchoption.alldirectory);
4 Respostas
+ 17
https://stackoverflow.com/questions/8821410/why-is-access-to-the-path-denied
Run Code as Admin... (find option in IDE).
Grant superuser/elevated privilledges to your program.
Fix file/folder readonly permissions.
+ 2
Thank you, ValentinHacker
+ 1
Try to make it smaller.
Try to create a file in "d:\", do you have rights there ?
if you use : Directory.getfiles(@"d:\"); does it work ?
If the small thing is working, you can go bigger.
SearchAllDirectory is a pretty huge area, you probably do not have access everywhere.
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-iterate-through-a-directory-tree
0
Thank you, @sneeze. :)
I just follow your suggestions.
and found that it is a problem of permission like @ValentinHacker's mention above. because when i skip secured folder, it work well.