Results 1 to 13 of 13

Thread: [RESOLVED] Problem with FTP

  1. #1
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Resolved [RESOLVED] Problem with FTP

    Hi,

    I am new to FTP Concept . Last two days i have been searching on the internet about and got the following example

    Code:
    Dim ftp As FTPClass
    Dim f As FTPFileClass
    Set ftp = New FTPClass
    If ftp.OpenFTP("ftp://ftp.<machine ip>", "root", "P@ssw0rd") Then
    MsgBox "Connected"
    If ftp.SetCurrentFolder("\temp\") Then
            MsgBox "inside second if"
             For Each f In ftp.Files
                MsgBox "inside for block"
                ftp.GetFile f.FileName, DownLoadFolder & "\" & f.FileName, True
             Next
    End If
    ftp.CloseFTP
    Else
    MsgBox "Not Connected"
    End If
    Set ftp = Nothing
    Instead of creating an ftp server, i am treating another machine as ftp server and i am passing that machine ip. When i am running the above code i am always getting the message "Not Connected" Please guide me where i am doing . I am enclosing class files also. Port number is 20.

    Thanks in Advance
    Attached Files Attached Files

  2. #2
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Re: Problem with FTP

    Quote Originally Posted by mahesh.sanka View Post
    Hi,

    I am new to FTP Concept . Last two days i have been searching on the internet about and got the following example

    Code:
    Dim ftp As FTPClass
    Dim f As FTPFileClass
    Set ftp = New FTPClass
    If ftp.OpenFTP("ftp://ftp.<machine ip>", "root", "P@ssw0rd") Then
    MsgBox "Connected"
    If ftp.SetCurrentFolder("\temp\") Then
            MsgBox "inside second if"
             For Each f In ftp.Files
                MsgBox "inside for block"
                ftp.GetFile f.FileName, DownLoadFolder & "\" & f.FileName, True
             Next
    End If
    ftp.CloseFTP
    Else
    MsgBox "Not Connected"
    End If
    Set ftp = Nothing
    Instead of creating an ftp server, i am treating another machine as ftp server and i am passing that machine ip. When i am running the above code i am always getting the message "Not Connected" Please guide me where i am doing . I am enclosing class files also. Port number is 20.

    Thanks in Advance
    The other guy has been using FileZilla and operating system is linux. In linux ftpsever comes by default. We need to install or configure any ftp server on it. So i have treated his machine as ftp server and my machine as ftpclient. Now i want to connect to it. through code

  3. #3
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,529

    Re: Problem with FTP

    When i am running the above code i am always getting the message "Not Connected"
    we would have to assume that there is something wrong with your connection
    If ftp.OpenFTP("ftp://ftp.<machine ip>", "root", "P@ssw0rd") Then
    ip address, user or password
    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
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Smile Re: Problem with FTP

    Quote Originally Posted by westconn1 View Post
    we would have to assume that there is something wrong with your connection

    ip address, user or password
    Yes. I thinks so

    Because when i am using INET control with the following code

    Code:
    Inet1.URL = "ftp://ftp.192.168.3.43"
    Inet1.Username = "root"
    Inet1.Password = "P@ssw0rd"
    Inet1.Execute , "DIR"
    Code:
    Private Sub Inet1_StateChanged(ByVal State As Integer)
    Dim data As String
    Dim data1 As String
    
        Select Case State
          Case icError
             MsgBox Inet1.ResponseInfo, , "File failed to transfer"
          Case icResolvingHost
             Label6.Caption = "Resolving Host"
          Case icHostResolved
              Label6.Caption = "Host Resolved"
          Case icConnecting
              Label6.Caption = "Connecting Host"
          Case icConnected
              Label6.Caption = "Host connected"
          Case icReceivingResponse
              Label6.Caption = "Receiving Response"
          Case icResponseReceived
              Label6.Caption = "Got Response"
          Case icResponseCompleted
              MsgBox "Transfer Completed"
            Do
                data1 = Inet1.GetChunk(1024, icString)
                data = data & data1
                Loop While Len(data1) <> 0
                Text6.Text = data
            End Select
    End Sub
    I am getting following error

    Unable to connect to remote host

  5. #5
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Re: Problem with FTP

    Quote Originally Posted by westconn1 View Post
    we would have to assume that there is something wrong with your connection

    ip address, user or password
    Hi westconn,

    When i am using the following code , still i am getting the following error Run time error 35754
    "Unable Connect to Remote Host"
    Code:
    Inet1.URL = "ftp://ftp.microsoft.com"
    Inet1.Username = "anonymous"
    Inet1.Password = ""
    Inet1.Execute "DIR"
    where every thing is correct.

    Do i need to make any changes in the above code

  6. #6
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,529

    Re: Problem with FTP

    do you need to connect?
    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

  7. #7
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Cool Re: Problem with FTP

    Quote Originally Posted by westconn1 View Post
    do you need to connect?
    Hi Westconn,

    Thanks for your reply

    Actually I am trying to extract the directories in that server . So when i use above command . error is coming.

  8. #8
    PowerPoster
    Join Date
    Jan 08
    Posts
    6,781

    Re: Problem with FTP

    Quote Originally Posted by mahesh.sanka View Post
    Hi westconn,

    When i am using the following code , still i am getting the following error Run time error 35754
    "Unable Connect to Remote Host"


    Code:
    Inet1.URL = "ftp://ftp.microsoft.com"
    Inet1.Username = "anonymous"
    Inet1.Password = ""
    Inet1.Execute , "DIR"
                  |
                  |
                  X
    where every thing is correct.

    Do i need to make any changes in the above code


    Use comma
    Last edited by jmsrickland; Sep 10th, 2012 at 01:08 PM.
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  9. #9
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Red face Re: Problem with FTP

    Quote Originally Posted by jmsrickland View Post
    Use comma
    Hi jmsrickland,

    Thanks for your reply. As per your suggestion i have used the comma, still i am facing the same problem

    Code:
     
    Inet1.URL = "ftp://ftp.microsoft.com"
    Inet1.Username = "anonymous"
    Inet1.Password = ""
    Inet1.Execute , "DIR"
    Name:  Error.JPG
Views: 39
Size:  64.9 KB

  10. #10
    PowerPoster
    Join Date
    Jan 08
    Posts
    6,781

    Re: Problem with FTP

    Then you are having a problem that lies outside of your code. I copied your code exactly as is from post 5 and of course I had same problem you did. When I added the comma it worked perfectly; It made the connection. Are you sure you are even connected to the internet? Maybe a firewall issue? Something else we don't know about?

    Try below code. I copied it from Microsoft and it works perfectly


    Code:
    Private Sub Command1_Click()
     Inet1.URL = "ftp://ftp.microsoft.com"
     Inet1.UserName = "anonymous"
     Inet1.Password = ""
     Inet1.Execute , "DIR"
    End Sub
    
    Private Sub inet1_StateChanged(ByVal State As Integer)
     Dim vtData As Variant ' Data variable.
     
     Select Case State
       ' ... Other cases not shown.
       Case icError ' 11
         ' In case of error, return ResponseCode and
    
         ' ResponseInfo.
         vtData = Inet1.ResponseCode & ":" & _
         Inet1.ResponseInfo
    
       Case icResponseCompleted  ' 12
         Dim strData As String: strData = ""
         Dim bDone As Boolean: bDone = False
    
         ' Get first chunk.
         vtData = Inet1.GetChunk(1024, icString)
         DoEvents
    
         Do While Not bDone
           strData = strData & vtData
           ' Get next chunk.
           vtData = Inet1.GetChunk(1024, icString)
           DoEvents
    
           If Len(vtData) = 0 Then
             bDone = True
           End If
         Loop
    
         MsgBox strData
     End Select
    End Sub
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  11. #11
    PowerPoster
    Join Date
    Jan 08
    Posts
    6,781

    Re: Problem with FTP

    Then you are having a problem that lies outside of your code. I copied your code exactly as is from post 5 and of course I had same problem you did. When I added the comma it worked perfectly; It made the connection. Are you sure you are even connected to the internet? Maybe a firewall issue? Something else we don't know about?

    Try below code. I copied it from Microsoft and it works perfectly


    Code:
    Private Sub Command1_Click()
     Inet1.URL = "ftp://ftp.microsoft.com"
     Inet1.UserName = "anonymous"
     Inet1.Password = ""
     Inet1.Execute , "DIR"
    End Sub
    
    Private Sub inet1_StateChanged(ByVal State As Integer)
     Dim vtData As Variant ' Data variable.
     
     Select Case State
       ' ... Other cases not shown.
       Case icError ' 11
         ' In case of error, return ResponseCode and
    
         ' ResponseInfo.
         vtData = Inet1.ResponseCode & ":" & _
         Inet1.ResponseInfo
    
       Case icResponseCompleted  ' 12
         Dim strData As String: strData = ""
         Dim bDone As Boolean: bDone = False
    
         ' Get first chunk.
         vtData = Inet1.GetChunk(1024, icString)
         DoEvents
    
         Do While Not bDone
           strData = strData & vtData
           ' Get next chunk.
           vtData = Inet1.GetChunk(1024, icString)
           DoEvents
    
           If Len(vtData) = 0 Then
             bDone = True
           End If
         Loop
    
         MsgBox strData
     End Select
    End Sub
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  12. #12
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Cool Re: Problem with FTP

    Quote Originally Posted by jmsrickland View Post
    Then you are having a problem that lies outside of your code. I copied your code exactly as is from post 5 and of course I had same problem you did. When I added the comma it worked perfectly; It made the connection. Are you sure you are even connected to the internet? Maybe a firewall issue? Something else we don't know about?

    Try below code. I copied it from Microsoft and it works perfectly


    Code:
    Private Sub Command1_Click()
     Inet1.URL = "ftp://ftp.microsoft.com"
     Inet1.UserName = "anonymous"
     Inet1.Password = ""
     Inet1.Execute , "DIR"
    End Sub
    
    Private Sub inet1_StateChanged(ByVal State As Integer)
     Dim vtData As Variant ' Data variable.
     
     Select Case State
       ' ... Other cases not shown.
       Case icError ' 11
         ' In case of error, return ResponseCode and
    
         ' ResponseInfo.
         vtData = Inet1.ResponseCode & ":" & _
         Inet1.ResponseInfo
    
       Case icResponseCompleted  ' 12
         Dim strData As String: strData = ""
         Dim bDone As Boolean: bDone = False
    
         ' Get first chunk.
         vtData = Inet1.GetChunk(1024, icString)
         DoEvents
    
         Do While Not bDone
           strData = strData & vtData
           ' Get next chunk.
           vtData = Inet1.GetChunk(1024, icString)
           DoEvents
    
           If Len(vtData) = 0 Then
             bDone = True
           End If
         Loop
    
         MsgBox strData
     End Select
    End Sub
    Thanks for your reply.
    I will work on this regard and will check my LAN Settings if any thing is getting blocked or firewall .

  13. #13
    Lively Member
    Join Date
    Oct 11
    Posts
    113

    Re: Problem with FTP

    Quote Originally Posted by mahesh.sanka View Post
    Thanks for your reply.
    I will work on this regard and will check my LAN Settings if any thing is getting blocked or firewall .
    Hi jmsrickland,

    Thanks my problem has been solved. This is because of proxy settings.

Posting Permissions

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