C
C#•3y ago
Meistro

denied accessing path string[] list1 = Directory.GetFiles(C_Drive, *.exe, SearchOption.AllDirectorie

Hei all, I am not able to iterate through my drive ... is it a security problem ? I already opened VS as Admin ERROR Message:
Unhandled exception. System.UnauthorizedAccessException: Access to the path 'C:\Documents and Settings' is denied.
at System.IO.Enumeration.FileSystemEnumerator`1.CreateRelativeDirectoryHandle(ReadOnlySpan`1 relativePath, String fullPath)
at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext()
at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
Unhandled exception. System.UnauthorizedAccessException: Access to the path 'C:\Documents and Settings' is denied.
at System.IO.Enumeration.FileSystemEnumerator`1.CreateRelativeDirectoryHandle(ReadOnlySpan`1 relativePath, String fullPath)
at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext()
at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
Thanks in Advance for any Help 🙂
5 Replies
Meistro
MeistroOP•3y ago
@mtreit ^^ sorry for pinging
mtreit
mtreit•3y ago
That's normal
mtreit
mtreit•3y ago
mtreit
mtreit•3y ago
You will need to handle the exception and skip things you don't have access to. That particular folder is not really a folder - it's a special "Junction Point" used by the OS.
Meistro
MeistroOP•3y ago
ahh ok Thank you 🙂
Want results from more Discord servers?
Add your server