将所有网站列入文本框

时间:2014-02-11 18:18:54

标签: vb.net iis-7

代码示例

Imports System.ServiceProcess
Imports System.Management
Imports System.Text.RegularExpressions
Imports System.Net.Sockets.TcpListener
Imports System.Text
Imports System.Net.NetworkInformation
Imports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Net
Imports System.Reflection
Imports System.Net.Sockets
Imports System.IO
Imports Microsoft.Web.Administration
Imports Microsoft.Web.Management



Private Sub GetAllSites()
    Dim iisManager As New ServerManager()
    Dim sitename As ArrayList = New ArrayList()
    sitename.Add(iisManager.Sites)
    For Each site As Object In sitename
        ListBox1.Items.Add(site)
    Next
End Sub

我要做的是将本地方框中IIS中运行的所有网站列在最好是数组的列表框中。

当代码执行时,它会写“(Collection)”

如果有人能告诉我哪些地方可能会出错,那将非常感激。

1 个答案:

答案 0 :(得分:1)

尝试这应该工作

Private Sub GetAllSites()
    Dim iisManager As New ServerManager()
    For Each sitename In iisManager.Sites
        ListBox10.Items.Add(sitename)
    Next



End Sub