Results 1 to 4 of 4

Thread: [RESOLVED] FTP Inet1 List Directories In ListView Control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Location
    EG
    Posts
    87

    Resolved [RESOLVED] FTP Inet1 List Directories In ListView Control

    Hello,
    I have VB6.0 Project with Inet1, i don't want to use API functions in this project, and i want to list directories from FTP server (i.e: ftp://ftp.mcafee.com) in a listView Control ....
    Note :
    i successfully connect to the server using
    Code:
    Inet1.Execute ,"DIR"

    Then i retrieve the Directories NAMES in textbox
    Code:
    DO
    data1 = inet1.getchunk(1024,icString)
    data = data + data1
    loop while len(Data1) <> 0
    text1.text = data
    .....
    Now i want to replace the Text1 with ListView , but when i attempt to do so, i get the result in just one line in the listview (folder1/folder2/folder3......etc) ... what is the right way to accomplish this task ?!

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: FTP Inet1 List Directories In ListView Control

    You need to split results using carriage return, for this you need an array, then loop this array adding Listitems (rows) to the Listview, example:
    Code:
    Private Sub Command1_Click()
    Dim Data1 As String, sData As String
    Dim lArrData() As String, i As Long
           
        Inet1.Execute , "DIR"
        
        Do While Inet1.StillExecuting
            DoEvents
        Loop
            
        Data1 = Inet1.GetChunk(1024, icString)
        
        Do While Len(Data1) <> 0
            sData = sData & Data1
            Data1 = Inet1.GetChunk(1024, icString)
        Loop
        
        lArrData = Split(sData, vbNewLine)
        
        For i = 0 To UBound(lArrData)
            LV.ListItems.Add , , lArrData(i)
        Next
        
    End Sub
    
    Private Sub Form_Load()
        LV.View = lvwReport
        LV.ColumnHeaders.Add 1, "folder", "Folder", 2000 'If you already added a column then delete this line
        Inet1.URL = "ftp://ftp.mcafee.com"
    End Sub
    I used Report view but you could use icons instead if you want, you can also add an ImageList control and use folder icons for each item, with this it would look much better.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: FTP Inet1 List Directories In ListView Control

    i posted an example to fill a treeview with a folder tree, using a shell object and FTP APIs in codebank
    http://www.vbforums.com/showthread.p...t=treeview+ftp

    neither method uses the Inet control, but may be worth consideration
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Location
    EG
    Posts
    87

    Re: FTP Inet1 List Directories In ListView Control

    Thank guys you both were a big help ....
    I rated both of you .
    Last edited by evry1falls; Apr 28th, 2012 at 04:20 PM. Reason: forgot to rate

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width