[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 ?!
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.
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
Re: FTP Inet1 List Directories In ListView Control
Thank guys you both were a big help ....
I rated both of you .