0

I'm developing a project in which it is required to Communicate with Mitsubishi M70 CNC (an FTP server) through VB6. Though my initial Communication with it is successful, when I try to upload or download file to it ,following error occurs :

Error 120003

200 Type set to I
200 Port command successful
500 Cannot Copy file/Directory. Permission Denied.

I'm able to COPY and paste the Files in the folder manually. But When I try to do the same through VB , it is showing error.

MY Project VB exe is installed on the same PC as my FTP server is .

My code is as follows

Option Explicit

Private m_GettingDir As Boolean
Private Sub AddMessage(ByVal msg As String)
    txtResults.Text = txtResults.Text & vbCrLf & msg
    txtResults.SelStart = Len(txtResults.Text)
End Sub



Private Sub cmdUpload_Click()
Dim host_name As String
Dim CMD2 As String

    Enabled = False
    MousePointer = vbHourglass
    txtResults.Text = "Working"
    txtResults.SelStart = Len(txtResults.Text)
    DoEvents

   ' You must set the URL before the user name and
   ' password. Otherwise the control cannot verify
   ' the user name and password and you get the error:
   '
   '       Unable to connect to remote host

   inetFTP.URL = "ftp://Administrator:CNC@NCExplorer:8080/(192,168,1,101)/"
   inetFTP.UserName = "Administrator"
   inetFTP.Password = "CNC"



   ' This is the path where Remote File is to be Copied


    CMD2 =   "ftp://Administrator:CNC@NCExplorer:8080/(192,168,1,101)/CNC%20MEMORY/PRG/USER/NEW_test.txt"

    'Is the syntax  of Remote file  path  Correct? I dont want to copy the   file in Home directory 

    '  Execution 

     inetFTP.Execute , "PUT C:\TEST.TXT CMD2"



  '    m_GettingDir = True
   '    inetFTP.Execute , "Dir"
  End Sub
Private Sub inetFTP_StateChanged(ByVal State As Integer)
    Select Case State
        Case icError
            AddMessage "Error: " & _
                "    " & inetFTP.ResponseCode & vbCrLf & _
               "    " & inetFTP.ResponseInfo
        Case icNone
            AddMessage "None"
        Case icConnecting
            AddMessage "Connecting"
        Case icConnected
            AddMessage "Connected"
        Case icDisconnecting
            AddMessage "Disconnecting"
        Case icDisconnected
            AddMessage "Disconnected"
        Case icRequestSent
            AddMessage "Request Sent"
        Case icRequesting
            AddMessage "Requesting"
        Case icReceivingResponse
            AddMessage "Receiving Response"
        Case icRequestSent
            AddMessage "Request Sent"
        Case icResponseReceived
            AddMessage "Response Received"
        Case icResolvingHost
            AddMessage "Resolving Host"
        Case icHostResolved
            AddMessage "Host Resolved"

        Case icResponseCompleted
            AddMessage inetFTP.ResponseInfo

        If m_GettingDir Then
            Dim txt As String
           Dim chunk As Variant
           m_GettingDir = False

             'Get the first chunk.
           chunk = inetFTP.GetChunk(1024, icString)
           DoEvents
            Do While Len(chunk) < 0
                txt = txt & chunk
                chunk = inetFTP.GetChunk(1024, icString)
                DoEvents
            Loop

         '  AddMessage "----------"
            AddMessage txt
        End If

   Case Else
        AddMessage "State = " & Format$(State)
End Select

Enabled = True
MousePointer = vbDefault
End Sub
Gatogordo
  • 2,629
  • 2
  • 22
  • 32
sst
  • 1
  • 2

1 Answers1

0

You're not giving the ftp cpommand a chance to see the final location. It's taking the location literally as CMD2

Try concatenating the destination string to the command

Change this:

inetFTP.Execute , "PUT C:\TEST.TXT CMD2"

To this

inetFTP.Execute , "PUT C:\TEST.TXT " & CMD2
dbmitch
  • 5,361
  • 4
  • 24
  • 38