为什么我会收到拒绝访问错误的Documents and Settings文件?我会、错误、文件、Documents

由网友(忘得洒脱)分享简介:我正在写一个程序,获取所有目录和子目录。我用下面的code:I'm writing a program that gets all directories and sub-directories. I'm using the following code:DriveInfo[] drives = DriveInfo...

我正在写一个程序,获取所有目录和子目录。我用下面的code:

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);
}

但我发现了一个异常,指出访问路径。C: Documents和Settings '被拒绝

But I'm getting an exception stating "Access to the path 'C:Documents and Settings' is denied."

我使用的是Windows 7和我没有看到一个C: Documents和Settings 文件夹在资源管理器。我启用了显示所有文件和文件夹,甚至尝试直接路径类型,但它提供了以下错误:C: Documents和设置为不可访问拒绝访问

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."

为什么 Directory.GetDirectories()拉似乎并不存在的目录?

Why is Directory.GetDirectories() pulling a directory that doesn't seem to exist?

推荐答案

这个目录是所谓的一个的结点,应指向C:用户

This directory is what is known as a junction point, which should be pointing to c:users.

从MSDN文档:

这些结点可以被确定如下:

These junction points can be identified as follows:

他们有FILE_ATTRIBUTE_REPARSE_POINT,FILE_ATTRIBUTE_HIDDEN和FILE_ATTRIBUTE_SYSTEM文件属性设置。

They have the FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_HIDDEN, and FILE_ATTRIBUTE_SYSTEM file attributes set.

他们也有自己的访问控制列表(ACL)设置为拒绝读取权限的每一个人。

They also have their access control lists (ACLs) set to deny read access to everyone.

应用程序调用了一个特定的路径,如果他们有必要的权限可以遍历这些结合点。然而,试图枚举结点的内容将导致故障。

Applications that call out a specific path can traverse these junction points if they have the required permissions. However, attempts to enumerate the contents of the junction points will result in failures.

阅读全文

相关推荐

最新文章