0x80005008L E_ADS_BAD_PARAMETER One or more input parameters are
invalid.

解决方案 »

  1.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/generic_adsi_error_codes.asp
      

  2.   

    >>再用find方法访问代码:
      

  3.   

    代码如下:
    DirectoryEntry rootfolder = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT"); 
    DirectoryEntry de = rootfolder.Children.Find("docula","IIsVirtualDir");
      

  4.   

    这个问题我刚刚解决掉,
    你的Find()函数的第二个参数应该是"IIsWebVirtualDir",而不是"IIsVirtualDir"或者你用 deRoot.SchemaClassName 肯定也不会错
      

  5.   

    送人送到底,送佛送到西。我看你给变量取名de,是不是想删除虚拟目录啊?我刚刚碰到这个问题就是在我想删除虚拟目录时碰到的。我把我的删除代码贴出来可能你会用到。public bool DeleteVirtualDirectory(string nameDirectory)
    {
    DirectoryEntry folderRoot = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
    try
    {
    DirectoryEntry deVirDir = folderRoot.Children.Find(nameDirectory,VirDirSchemaName);  folderRoot.Children.Remove(deVirDir); folderRoot.CommitChanges();
    }
    catch
    {
    return false;
    }
    return true;
    }
      

  6.   

    忘了说,我的变量 VirDirSchemaName = "IIsWebVirtualDir";
      

  7.   

    我以前用vbs写过类似的,没有用.net写过
    你参考一下:
    Function CreateVirtualFolder(strMachineName,strParentPath ,strVirtualFolder, strAppName, strPath)
    '        On Error Resume Next        Dim IIsObject
            Dim IIsObjectPath
            Dim IIsObjectRelativePath
            Dim NewObject
            Dim ObjectTypeName
            Dim ParentObjPath
            Dim ParentObjSize
            Dim FullAdsParentPath
            Dim MachineName
            Dim OpenErr        ' Set the return code - assume success
            CreateVirtualFolder = true
    ObjectTypeName="IIsWebVirtualDir" if len(trim(strMachineName))=0 or len(trim(strVirtualFolder))=0 or len(trim(strParentPath))=0 then
    CreateVirtualFolder = false
    Exit Function
    end if IIsObjectPath = strParentPath + "/" +strVirtualFolder        MachineName = strMachineName        ' Parse the path and determine if the parent exists.
            ParentObjSize = InStrRev(IIsObjectPath, "/")
            ParentObjPath = ""        If ParentObjSize <> 0 Then
                    ParentObjPath = Left(IIsObjectPath, ParentObjSize - 1)
                    IIsObjectRelativePath = Right(IIsObjectPath, Len(IIsObjectPath) - ParentObjSize)
            Else
                    IIsObjectRelativePath = IIsObjectPath
            End If        If ParentObjPath <> "" Then
                    FullAdsParentPath = "IIS://" & MachineName & "/" & ParentObjPath
            Else
                    FullAdsParentPath = "IIS://" & MachineName
            End If
            ' First, attempt to open the parent path and add the new path.
            Set IIsObject = GetObject(FullAdsParentPath)
            If Err.Number <> 0 Then
                    OpenErr = Err.Number
                    OpenErrDesc = Err.Description
                    Err.Clear
                    ' Attempt to get the Computer Object (IIS://LocalHost)
                    Set IIsObject = GetObject("IIS://" & MachineName)
                    If Err.Number <> 0 Then
    '                        WScript.Echo
    '                        ReportError ()
    '                        WScript.Echo "Error accessing the object: " & IIsObjectPath
    '                        WScript.Quit (Err.Number)
    CreateVirtualFolder = false
    Exit Function
                    End If
            End If

    IIsObject.AccessWrite = True 
    IIsObject.SetInfo If (OpenErr <> 0) Then
    WScript.Echo IIsObjectPath
    On Error Resume Next 
    Set NewObject = IIsObject.Delete(ObjectTypeName, IIsObjectPath)
    On Error GoTo 0
    Set NewObject = IIsObject.Create(ObjectTypeName, IIsObjectPath)
            Else
    'WScript.Echo "IIsObjectRelativePath" + IIsObjectRelativePath
    On Error Resume Next 
    Set NewObject = IIsObject.Delete(ObjectTypeName, IIsObjectRelativePath)
    On Error GoTo 0
    Set NewObject = IIsObject.Create(ObjectTypeName, IIsObjectRelativePath)
            End If        If Err.Number <> 0 Then
    CreateVirtualFolder = false
    Exit Function
            End If NewObject.Put "Path", strPath
    NewObject.Put "AccessRead", True
    NewObject.Put "AccessScript", True NewObject.AppCreate2 1
    NewObject.Put "AppFriendlyName",strAppName NewObject.Setinfo        If Err.Number <> 0 Then
             CreateVirtualFolder = false
    Exit Function
            End If
            If OpenErr <> 0 Then
                    CreateVirtualFolder = false
    Exit Function
            End If        If UCase(ObjectTypeName) = "IISOBJECT" Then
    CreateVirtualFolder = false
    Exit Function
            End IfEnd function