7 Replies - 5548 Views - Last Post: 13 September 2012 - 04:14 AM Rate Topic: -----

#1 evry1falls  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 25-April 12

FTP Inet - Open Directory and Display its content into listbox

Posted 01 May 2012 - 08:49 AM

Hello,
I have this project as attached,
i want to open (Directory) and display its content in the listbox .. but it is not working ....
i believe that everything is correct but im missing something .
Please see my project and suggest me an answer to try it ...

Attached File  FTP.zip (39.03K)
Number of downloads: 465

Is This A Good Question/Topic? 0
  • +

Replies To: FTP Inet - Open Directory and Display its content into listbox

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: FTP Inet - Open Directory and Display its content into listbox

Posted 01 May 2012 - 10:39 AM

Again, please post your relevant code directly (don't just put all of it here), for the reasons I gave in your other thread.
Was This Post Helpful? 1
  • +
  • -

#3 evry1falls  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 25-April 12

Re: FTP Inet - Open Directory and Display its content into listbox

Posted 01 May 2012 - 11:56 AM

Ok, here is my code :
1) The event Inet1_StateChanged, return the connection status.

Private Sub Inet1_StateChanged(ByVal State As Integer)
Istate = State
Select Case Istate
    Case Is = 1
        Label6.Caption = "The control is looking up the IP address of the specified host computer. (icHostResolvingHost)"
    Case Is = 2
        Label6.Caption = "The control successfully found the IP address of the specified host computer. (icHostResolved)"
    Case Is = 3
        Label6.Caption = "The control is connecting to the host computer. (icConnecting)"
    Case Is = 4
        Label6.Caption = "The control successfully connected to the host computer. (icConnected)"
    Case Is = 5
        Label6.Caption = "The control is sending a request to the host computer. (icRequesting)"
    Case Is = 6
        Label6.Caption = "The control successfully sent the request. (icRequestSent)"
    Case Is = 7
        Label6.Caption = "The control is receiving a response from the host computer. (icReceivingResponse)"
    Case Is = 8
        Label6.Caption = "The control successfully received a response from the host computer. (icResponseReceived)"
    Case Is = 9
        Label6.Caption = "The control is disconnecting from the host computer. (icDisconnecting)"
    Case Is = 10
        Label6.Caption = "The control successfully disconnected from the host computer. (icDisconnected)"
    Case Is = 11
        Label6.Caption = "An error occurred in communicating with the host computer. (icError)"
    Case Is = 12
        Label6.Caption = "The request has been completed and all data has been received. (icResponseCompleted)"
    Case Else
        Label6.Caption = "Unknown State"
End Select
End Sub


Note : (Istate) Variable was defined in module level (Public) to be heard in the whole project as String .


2) Form_Load event code opens (Log.txt) and pick up my stored info (HostURL,UserName,PassWord) .

3) The Connect button : Now here is my main problem, so far i'm able to connect to the (FTP://) using this code :

Private Sub Label9_Click()
'make sure remote server provided
If Text1.Text = Trim("") Then
    Label6.Caption = ("Please choose a remote server")
    Text1.SetFocus
    Exit Sub
End If
'Login/Connect Code
Inet1.AccessType = icDirect
Inet1.URL = Text1.Text
Inet1.UserName = Text2.Text
Inet1.Password = Text3.Text
Inet1.RequestTimeout = 40
Inet1.Execute , "DIR"
Do While Inet1.StillExecuting
    DoEvents: DoEvents: DoEvents
Loop
'////////////////////////////////////////////
Inet1_StateChanged (Istate)
'///////////////////////////////////////////
Select Case Check1.Value
    Case Is = 1
                Open App.Path & "/log.txt" For Output As #Nfile
                        Print #Nfile, Text1.Text
                        Print #Nfile, Text2.Text
                        Print #Nfile, Text3.Text
                        Print #Nfile, Check1.Value
                Close #Nfile
    Case Is = 0
                Exit Sub
End Select
End Sub



- It returns the connection status fine (Connected), but doesn't return any data from the server (FTP://) , so i've created another label_click event to display the Main Dir of the (FTP://) .

4) The event that displays Main Dir of the (ftp://) under the Label10_Click event :

Private Sub Label10_Click()
'make sure remote server provided
If Text1.Text = Trim("") Then
    Label6.Caption = ("Please choose a remote server")
    Text1.SetFocus
    Exit Sub
End If
'Make sure you are connected.
If Istate <> 12 Then ' Connected
    Label6.Caption = "sorry, you did not full successfully recieved a responce from the server."
    Exit Sub
End If
'Make Sure List is Empty (not to load data twice)
If List4.ListIndex <> -1 Then Exit Sub
'Get List of all files
StrDir = ""
List4.Clear
Do
DoEvents
Loop Until Not Inet1.StillExecuting
Data1 = Inet1.GetChunk(1024, icString)
Data = Data + Data1
StrDir = Data
Entry = Split(StrDir, vbCrLf, , vbTextCompare)
    XX = 0
 Do While XX < UBound(Entry)
        If Trim$(Entry(XX)) <> "" Then
            List4.AddItem Entry(XX)
        End If
        XX = XX + 1
    Loop
    If List4.ListCount = 0 Then
        List4.ListIndex = -1
    Else
        List4.ListIndex = 0
    End If
    End Sub


- To tell you the truth i did not come up with all of the (Label10) code i just worked around some other codes to get the result i needed, anyway it displays the Main Dir of the (ftp://), now when i try to execute any other ftp command, it just doesn't display anything for me, and when i try to work around this problem i get duplications in the (list4) displayed data.

- My problem is that i did not put the GetChunk code in the right place, coz it carries the same executed data everytime i try to change the Inet1 Command.

- I dunno where did i go wrong !
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: FTP Inet - Open Directory and Display its content into listbox

Posted 01 May 2012 - 12:50 PM

This complicated bit of code might give you some ideas. Note also this, which explains how GetChunk works. GetChunk gets a chunk of a BLOB, in your case a chunk of 1024 bytes. Then, the next time you call GetChunk, it will get the next 1024 bytes of your BLOB, and so on. You only call it once in your proc, and then everything starts over again. So, you're managing to start over each time you call GetChunk.

Most code loops around Getchunk until there isn't any data left. That might give you something to work through.
Was This Post Helpful? 1
  • +
  • -

#5 evry1falls  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 25-April 12

Re: FTP Inet - Open Directory and Display its content into listbox

Posted 04 May 2012 - 09:39 AM

Thanx, that really helped
Was This Post Helpful? 0
  • +
  • -

#6 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: FTP Inet - Open Directory and Display its content into listbox

Posted 05 May 2012 - 09:24 AM

Outstanding. :)
Was This Post Helpful? 0
  • +
  • -

#7 maheshsanka  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-September 12

Re: FTP Inet - Open Directory and Display its content into listbox

Posted 13 September 2012 - 03:09 AM

View Postevry1falls, on 04 May 2012 - 09:39 AM, said:

thanks, that really helped

Hi,

i am also facing same problem. May i know how you solve it
Was This Post Helpful? 0
  • +
  • -

#8 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 301
  • View blog
  • Posts: 1,782
  • Joined: 26-March 09

Re: FTP Inet - Open Directory and Display its content into listbox

Posted 13 September 2012 - 04:14 AM

Try reading through the links that Bob posted in regards to the OP's original problem.

If that doesn't help you, then open a new thread, showing your code and explaining the particular problem you have.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1