我正在尝试访问文件夹的子文件夹。以下是我的代码。
ConnectionOptions conn = new ConnectionOptions();
conn.Impersonation = ImpersonationLevel.Impersonate;
conn.Username = _userName;
conn.Password = _password;
ManagementScope theScope = new ManagementScope("\\\\" + selectedServer.IPAddress + "\\root\\cimv2", conn);
ManagementObjectSearcher servSearcher2 = new ManagementObjectSearcher(theScope, new ObjectQuery(@"ASSOCIATORS OF {Win32_Directory.Name ='c:\\users'} WHERE AssocClass = Win32_Subdirectory ResultRole = PartComponent "));
ManagementObjectCollection servObj1= servSearcher2.Get();
foreach (ManagementObject obj in servObj1){}
它给出错误"无效的对象路径"。知道我做错了什么吗?
答案 0 :(得分:0)
在Windows操作系统中,“..”文件夹是父文件夹的链接文件夹,会将您带到一个级别
你可以调用一个继续导航到“..”的循环,直到找到你要查找的文件夹名称。任何文件夹的“顶级文件夹”都是您的驱动器号(根目录)。但要小心,因为在每个目录中都会找到“..”(根目录除外),因此“..”将相对于您当前所在的文件夹。