|
-
Jul 17th, 2006, 10:53 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Detect inaccessible folders?
Hello everyone,
On each XP system the hidden system folder 'System Volume Information' appears in the root of each fixed drive. This folder is not accessible, not through the Explorer, not through VB. So, when I try to find out what subfolders this folder has, using IO.Directory.GetDirectories("C:\System Volume Information"), my program crashes.
I don't really need to know what subfolders the folder has, but my application checks for every folder whether or not it has subfolders.
So, how can I detect if a folder is accessible or not, without getting an error?
Thanks for any help,
arsmakman.
No matter how fool-proof your program is, there will always be a better fool.
Was a post helpful to you? Rate it!
-
Jul 17th, 2006, 12:03 PM
#2
Re: [2005] Detect inaccessible folders?
you should use error handling to catch any exceptions thrown when hitting a folder..
if the exception is permissions related, then you should bypass that folder. (perhaps have your app report what folders it could not gain access to)
I say this because this could be the case for ANY folder on a users system. They might have certain things locked down... a good example is that a non admin user account will not be able to see everyones folders in documents and settings.. only their own. Admins can view all the folders...
So anyway, with that being said.. if you just want to see the system volume information, you just need to give yourself permissions, because by default only the SYSTEM account has them. (these folders are part of the windows system restore feature)
http://support.microsoft.com/kb/309531/
-
Jul 17th, 2006, 03:56 PM
#3
Thread Starter
Fanatic Member
Re: [2005] Detect inaccessible folders?
I should have explained in more detail, as I do not need to access these folders.
I am making a TreeView with the user's file system's folders in it and it's working (almost) perfectly. I need to check if folders have subfolders, so I can add them to the tree. But, when I check for subfolders on a folder that is inaccessible, an exception is thrown. I don't really need to know if the inaccessible folder has subfolders. I just need to detect if it's accessible, so I won't get an error.
I will make it so that a warning message will appear, when a user tries to open an inaccessible folder.
Long story short: I need a way to tell if a folder is accessible by the current user or not. And it would be a lot nicer to actually detect this, in stead of error handling when an illegal operation is performed on such a folder.
Last edited by arsmakman; Jul 17th, 2006 at 04:02 PM.
No matter how fool-proof your program is, there will always be a better fool.
Was a post helpful to you? Rate it!
-
Jul 17th, 2006, 04:22 PM
#4
Re: [2005] Detect inaccessible folders?
well thats why they call it a try block
you try to do something, and handle the exception when it fails...
now I would imagine that when scanning through the file system on any given computer, the user SHOULD have access to more files than they don't have access to.
That being said, I imagine checking permissions on a folder BEFORE trying to access it, just for the sake of checking before trying will slow your program down..
it means you add an additional check on EVERY folder before trying to get its contents, versus just catching an exception on the few folders that you don't have permissions to.
Try/Catch blocks are not ONLY for catching user input errors and such.. they really have many uses.. and I would say this is one of them..
-
Jul 17th, 2006, 04:30 PM
#5
Thread Starter
Fanatic Member
Re: [2005] Detect inaccessible folders?
Kleinma, you're right. You've got me convinced. 
Thanks.
No matter how fool-proof your program is, there will always be a better fool.
Was a post helpful to you? Rate it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|