|
Как создать в IIS виртуальную директорию |
|
|
Как создать в IIS виртуальную директорию Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim strSchema As String
Dim strRootSubPath As String
If RadioButton1.Checked Then
strSchema = "IIsWebVirtualDir"
strRootSubPath = "/W3SVC/1/Root"
End If
If RadioButton2.Checked Then
strSchema = "IIsFtpVirtualDir"
strRootSubPath = "/MSFTPSVC/1/Root"
End If
If strSchema = "" Then
strSchema = "IIsWebVirtualDir"
strRootSubPath = "/W3SVC/1/Root"
End If
Dim deRoot As New DirectoryServices.DirectoryEntry("IIS://" + txtServer.Text & strRootSubPath)
Try
deRoot.RefreshCache()
Dim deNewVDir As DirectoryServices.DirectoryEntry = deRoot.Children.Add(txtVDirName.Text,
strSchema)
deNewVDir.Properties("Path").Insert(0, txtVDir.Text)
deNewVDir.CommitChanges()
deRoot.CommitChanges()
'Создать приложение
If strSchema = "IIsWebVirtualDir" Then
deNewVDir.Invoke("AppCreate", True)
'Сохранить изменения
deNewVDir.CommitChanges()
deRoot.CommitChanges()
deNewVDir.Close()
deRoot.Close()
lblStatus.Text = "Виртуальная директория " & txtVDirName.Text & "(" & txtVDir.Text & ")
была создана"
End If
Catch ex As Exception
lblStatus.Text = "Ошибка: " & ex.Message
End Try
End Sub
|
|
|
|
|
|
|