调用DirectoryEntry.Find(), 查找一个IIS的虚拟目录出错.
s = "Test";
DirectoryEntry rootfolder = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
DirectoryEntry newVirDir = rootfolder.Children.Add(s,"IIsWebVirtualDir");
newVirDir.Properties["AnonymousUserName"][0] = rootfolder.Properties["AnonymousUserName"][0] ;
newVirDir.Properties["AnonymousUserPass"][0] = rootfolder.Properties["AnonymousUserPass"][0];
newVirDir.Properties["AccessRead"][0] = true;
newVirDir.Properties["AccessExecute"][0] = true;
newVirDir.Properties["AccessWrite"][0] = false;
newVirDir.Properties["AuthBasic"][0] = false;
newVirDir.Properties["AuthNTLM"][0] = true;
newVirDir.Properties["ContentIndexed"][0] = false;
newVirDir.Properties["EnableDefaultDoc"][0] = true;
newVirDir.Properties["EnableDirBrowsing"][0] = false;
newVirDir.Properties["AccessSSL"][0] = false;
newVirDir.Properties["AccessScript"][0] = true;
newVirDir.Invoke("AppCreate",true);
newVirDir.Properties["DefaultDoc"][0] = "default.asp";
newVirDir.Properties["Path"][0] = "c:\\";
newVirDir.CommitChanges();
rootfolder.CommitChanges();
newVirDir.Close();
rootfolder.Close();
DirectoryEntry rootfolder2 = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
DirectoryEntry newVirDir2 = rootfolder2.Children.Find(s, "IIsWebVirtualDir");
产生异常
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in system.directoryservices.dll
Additional information: Exception from HRESULT: 0x80005008.
调试发现目录创建成功, 在执行FIND的时候出错.
谢谢