I'm writing a program that gets all directories and sub-directories. I'm using the following code:
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
string[] directories = Directory.GetDirectories(drive.Name, "*", SearchOption.AllDirectories);
}
But I'm getting an exception stating "Access to the path 'C:Documents and Settings' is denied."
I'm using Windows 7 and I don't see a C:Documents and Settings folder in Explorer. I enabled "Show hidden files and folders" and even try to type in the path directly but it gives the following error: "C:Documents and Settings is not accessible. Access denied."
Why is Directory.GetDirectories()
pulling a directory that doesn't seem to exist?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…