Jump to content
  • Advertisement
Sign in to follow this  
LycaonX

VS2010 VB app not catching UnauthorizedAccessException inside Try/Catch block

This topic is 2860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to enumerate through the root of my C:\ Drive on Vista, running under an admin account and also running the IDE as administrator, as well as having attempted to run the binary exe as administrator. No matter what I do, I (apparently properly) am denied access to C:\Documents and Settings, which I do not care about enumerating and which doesn't even show up in Explorer with hidden items shown. Anyway, in XP, to skip over folders the user didn't have access to I'd use the following code, which worked fine. However, on Vista, the try/catch block is NOT catching the UnauthorizedException. /confused

Any thoughts? The Framework's no good if a try/catch isn't going to catch an exception

Edit: I do realize I can work around it with an if statement to check for the specific folder, but what if the OS install drive is not C:\? What other folders are going to cause the same problem?


Sub SearchFolder(Folder As String)
Try
Dim Folders() As String = Directory.GetDirectories(Folder) ' UnauthorizedException here when trying to access C:\Documents and Settings, not being caught in the catch area
For Each f As String In Folders
SearchFolder(f)
Next
Catch ex As Exception
Stop
End Try
' Other stuff done here
End Sub


[Edited by - LycaonX on October 20, 2010 9:47:29 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!