"System Volume Information" directory

  • Thread starter Thread starter Krazitchek
  • Start date Start date
K

Krazitchek

Hi, i check all directories on a disk but an error occurs
when i try to enter in the "System Volume Information"
directory.

Is there a way to "jump" this directory without to check
the name of the current directory to verify it's
not "System Volume Information" ?

Or, how to catch this error and continue the process when
the error occurs ?

Thanks.
 
Just checking the name wouldn't be safe at all times either, other
directories may throw permission errors.
basically, you need to wrap your code in try-catch blocks, something like
string[] directories = <get folders>;
foreach (string directory in directories)
{
try
{
//do wahtever you need to with the directory.
}
catch (IOException ioe) {
//handle IOException conditions
}
catch (UnauthorizedAccessException uae) {
//handle UnauthorizedAccessException conditions
}
finally {
//do any code that must occur in any case.
}
}

should suffice, UnauthorizedAccessException should handle filesystem
permission issues, the documentation for the various IO methods will have
more information on what specific exceptions they can throw.
You should be able to find more information on exception handling in msdn.
 
Back
Top