GetFiles returns "Access to the path 'C:\System Volume Information' is denied."

  • Thread starter Thread starter Rob R. Ainscough
  • Start date Start date
R

Rob R. Ainscough

I'm not sure why I'm getting this error when searching thru my local hard
drives using My.Computer.FileSystem.GetFiles?

I've got FileIOPermissions set in code:

Dim f As New FileIOPermission(PermissionState.Unrestricted)
f.AllFiles = FileIOPermissionAccess.AllAccess

But I still get this error? Any work arounds to this?

Rob.
 
Hello Rob,
Local Admins and Domain Admins can't even access this folder. I don't know
why *exactly*.. but that's just how it is.

-Boo
 
I came up with a work-around, basically from the root use the GetDirectories
filter to search TopLevelOnly and check for System Volume Information, then
do a GetFiles on a "valid" dir.

As usual, the MSDN samples don't work as presented and NO documentation
(except on Feedback site) on this issue at all. So a 2 minute job ends up
being another R&D hunt wasting hours.
 
Local Admins and Domain Admins can't even access this folder. I don't know
why *exactly*.. but that's just how it is.

Because the ACL on the folder are set so that only the local system
account have access to it by default.


Mattias
 
but I'm able to read the information just nothing below it -- the real issue
is a bug in the .NET routine -- it should be able to deal with the
situation -- just missing bounds checking which is primary cause of 80% of
software bugs -- sloppy code from M$ that is known, but has not been made a
priority because a work around exists.
 
Hello Rob,

It's not a bug or sloppy M$ code. As Mattias said, the ACL doesnt allow
an interactive user to access that directory. You could easily mark any
directory/file to prevent certain users from accessing them.. In which case
your code would fail if run as one of those restricted users.

Wrap your code in a Try catch block.

-Boo
 
Back
Top