有没有人知道'etc‘在目录枚举方面有什么特别之处,有没有其他类似的东西,以及如何避免它不可见?
public class Foo
{
[Test]
public void Etc()
{
var etc = new DirectoryInfo(@"C:\Windows\System32\drivers\etc");
Assert.True(etc.Exists);
/* Expected: not <empty> But was: <empty> */
Assert.IsNotEmpty(etc.Parent.GetDirectories(etc.Name));
}
}发布于 2013-03-08 21:50:00
您将代码作为32位进程在64位计算机上运行。你可以看到file system redirector的效果
对于32位或64位进程,C:\Windows\system32\drivers\etc不会被重定向(文档记录为免除重定向),C:\windows\system32\drivers\etc也不会被重定向。
但是,当您使用C:\windows\system32\drivers时,如果您在32位进程中运行,则会被重定向至C:\Windows\SysWow64\drivers。并且该目录下没有etc目录。
发布于 2013-03-08 21:48:14
嗯..。这可能是权限问题(可能是读权限),但如果是这样的话,您可能会得到一个错误。
使用上的Directory.GetDirectories(@"C:\Windows\System32\drivers")方法查看它是否出现。
这是documentation。
https://stackoverflow.com/questions/15295277
复制相似问题