C#拒绝访问路径"C:\ Documents and Settings \"

编程入门 行业动态 更新时间:2024-10-27 18:34:08
本文介绍了C#拒绝访问路径"C:\ Documents and Settings \"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用一个简单的DirectoryInfo来获取C驱动器根目录上的所有目录.但是,我在管理员下运行,并且遇到路径访问被拒绝的错误,下面是我正在运行的代码.如何解决路径访问问题?

I'm using a simple DirectoryInfo to grab all directories on the root on the C drive. However, I'm running under administrator and i'm getting the error of path access denied, below is the code that I am running. How do I resolve the issue of path access?

DirectoryInfo Dinfo = new DirectoryInfo(@"C:\"); DirectoryInfo[] directories = Dinfo.GetDirectories("*.*", SearchOption.AllDirectories);

推荐答案

在Windows的较新版本中,C:\Document and Settings是连接点,是一种文件系统快捷方式.它不是普通目录,这意味着它实际上不能用作普通目录.

On newer versions of Windows C:\Document and Settings is a junction point, kind of a file system shortcut. It is not a normal directory, which means that it doesn't really work as a normal directory.

如果在开始"->运行"框中键入C:\Document and Settings,也会收到拒绝访问错误,因此它与您的程序无关.

If you type in C:\Document and Settings in the start->run box you will also get an access denied error, so it is nothing specific to your program.

但是我对它的工作方式有些困惑.我以为接合点将是指向新位置c:\users的透明链接,但显然不是.

I'm a bit confused by how this works however. I thought that the junction point would be a transparent link to the new location which is c:\users but obviously not.

看完重复的问题后,我就不那么困惑了.交界点实际上链接到新位置c:\users.但是,在连接点上有一个明确的拒绝ACL来读取,以防止任何人使用它来读取内容:

After looking at the duplicate question I'm less confused. The junction point really links to the new location which is c:\users. However, there is an explicit deny acl for reading on the junction point to prevent anyone from using it to read things:

C:> cacls文档和设置" C:\ Documents and Settings 所有人:(DENY)(特殊访问权限:)

C:>cacls "Documents and Settings" C:\Documents and Settings Everyone:(DENY)(special access:) FILE_READ_DATA Everyone:R NT AUTHORITY\SYSTEM:F BUILTIN\Administrators:F

C:>

更多推荐

C#拒绝访问路径"C:\ Documents and Settings \"

本文发布于:2023-11-08 02:31:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568083.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   quot   Settings   Documents

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!