当前位置:编程学习 > VB >>

VB中关于listview 显示FTP指定目录

用下面的代码已经能够显示FTP根目录   但我显示不了指定文件夹的目录 
比如我要显示FTP 目录内  2011年   这个文件夹内的文件名的列表  
在网上查的是用  Execute , "DIR /2011年"
但listview 显示一片空白
请问是为什么   如果不对请指出我该改哪些 
或者有别的方法达到也可以


Private Sub Cmdlist_Click()


If Inet1.StillExecuting Then
    MsgBox "无法断开连接"
    Exit Sub
End If
'列出服务器根目录
listserver
End Sub

'列出服务器指定目录下的文件和子目录
Private Sub listserver()
    If Not Inet1.StillExecuting Then
        OperationStyle = 1
        Inet1.Execute , "DIR"
    End If
    Exit Sub
End Sub
Private Sub deallist(tempstr As String)
If Right(Trim(tempstr), 1) <> "/" Then
    '表示接受到的是文件
    addfiletolist (tempstr)
Else
    '表示接受到的是目录
    adddirtolist (tempstr)
End If
End Sub
'将文件名加入到列表视图中
Private Sub addfiletolist(tempstr As String)
Dim itmx As ListItem
    Set itmx = ListView1.ListItems.Add(, , tempstr)
End Sub
'将目录加入到列表视图中
Private Sub adddirtolist(tempstr As String)
Dim itmx As ListItem
    Set itmx = ListView1.ListItems.Add(, , tempstr)
End Sub

Private Sub Cmddownload_Click()


Text1.Text = Text1.Text & "成功下载……"
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
    Case 0
    Case 1
        Text1.Text = Text1.Text & vbCrLf & "正在查询所指定的主机的IP地址"
    Case 2
        Text1.Text = Text1.Text & vbCrLf & "成功地找到所指定的主机的IP地址"
    Case 3
        Text1.Text = Text1.Text & vbCrLf & "正在与主机连接"
    Case 4
        Text1.Text = Text1.Text & vbCrLf & "已与主机连接成功"
    Case 5
        Text1.Text = Text1.Text & vbCrLf & "正在向主机发送请求"
    Case 6
        Text1.Text = Text1.Text & vbCrLf & "发送请求已成功"
    Case 7
        Text1.Text = Text1.Text & vbCrLf & "在接收主机的响应"
    Case 12
                Select Case OperationStyle
            Case 2
                Text1.Text = Text1.Text & vbCrLf & "成功改变目录"
                listserver
            Case Else
                Text1.Text = Text1.Text & vbCrLf & "成功列出目录"
                ListView1.ListItems.Clear
                inetdata = Inet1.GetChunk(1024, 0)
                If Trim(inetdata) <> 0 Then
                    temparray = Split(inetdata, vbCrLf, , vbTextCompare)
                    i = 0
                    Do While i < UBound(temparray)
                        If temparray(i) <> "" Then
                            deallist (temparray(i))
                        End If
                        i = i + 1
                    Loop
                End If
        End Select
    End Select
        Text1.SelLength = Len(Text1.Text)
End Sub --------------------编程问答-------------------- 这样贴代码看得头晕。
补充:VB ,  网络编程
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,