我现在有一个难题了,就是我的一个程序需要将当前存在虚拟目录下的实际路径更改?如果知道删除虚拟目录也可以?有代码最好了

解决方案 »

  1.   

    see the example athttp://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=Ob59%23ZYdBHA.1488%40tkmsftngp02
      

  2.   

    Dim oIIS, oDir, oFile,a
    Dim sName, sPath,sName1, sPath1sPath = 'Enter the path here
    sPath1 = 'Enter the path here for the sub Virtual directory
    sName = 'Name of the Virtual directory
    sName1 = 'Name of the sub Virtual directorySet oFile = CreateObject("Scripting.FileSystemObject")
        Set a = oFile.CreateTextFile("c:\testfile.txt", True)
        a.WriteLine(sPath)
        a.WriteLine(sName)
    Set oIIS = GetObject("IIS://localhost/W3SVC/1/Root")
    On Error Resume Next
    Set oDir = oIIS.GetObject("IISWebVirtualDir", sName)
    ' This will return error -2147024893 if it doesn't exist
    a.WriteLine(Err.Number)
    if Err.Number = 0 Then oIIS.Delete "IISWebVirtualDir", sName
       oIIS.SetInfo
    a.WriteLine(Err.Number)
    If Err.Number <> 0 Then Set oDir = oIIS.Create("IISWebVirtualDir", sName)
    a.WriteLine(Err.Number)
     oDir.AuthAnonymous = false
    Err.Clear
    oDir.AccessScript = True
    oDir.Path = sPath'Create the virtual subdirectory
        Set oDir = oIIS.Create("IISWebVirtualDir", sName & "/" & sName1)
            oDir.AccessRead = True
            oDir.AccessWrite = True
            oDir.path = sPath1
            oDir.SetInfo
            oDir.AppCreate True
            oDir.SetInfo
    a.Close
    ' Workaround for bug in II4
    oDir.KeyType = "IIsWebVirtualDir"oDir.SetInfo
    oDir.AppCreate True
    oDir.SetInfo
    Set oDir = Nothing
    Set oIIS = Nothing