【问题标题】:FTP Files Upload Error in VB6VB6 中的 FTP 文件上传错误
【发布时间】:2016-07-25 14:12:49
【问题描述】:

我正在开发一个需要通过 VB6 与 Mitsubishi M70 CNC(FTP 服务器)通信的项目。虽然我与它的初始通信成功,但当我尝试向它上传或下载文件时,出现以下错误:

Error 120003

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

我可以手动复制并粘贴文件夹中的文件。但是当我尝试通过 VB 做同样的事情时,它显示错误。

MY Project VB exe 安装在与我的 FTP 服务器相同的 PC 上。

我的代码如下

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

【问题讨论】:

    标签: ftp vb6 ftp-client cnc


    【解决方案1】:

    您没有给 ftp 命令一个查看最终位置的机会。它以 CMD2 的形式获取位置

    尝试将目标字符串连接到命令

    改变这个:

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

    到此

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-27
      • 1970-01-01
      • 2012-05-13
      • 2014-10-21
      相关资源
      最近更新 更多