如果源文件所处目录带有空格怎么办,例如inet1.execute str_URL, 'put c:\Program Files\Microsoft SQL Server\A.TXT A.TXT'不出错,但是无法真正传到服务器上,请哪位大侠帮助解决!

解决方案 »

  1.   

    Public Sub FtpUpLoad(strUploadFileName As String)
        blnFtpFinishFlag = False
        
        On Error GoTo ErrorHandler    With InternetConnection
            .URL = strFtpURL
            .UserName = strFtpUser
            .Password = strFtpPassword
            .Execute , "PUT " + strLocalPath + strUploadFileName + " " + strRemotePath + strUploadFileName
        End With    '等待Ftp执行结束
        Do While InternetConnection.StillExecuting = True
            DoEvents
        Loop
            
        InternetConnection.Execute , "CLOSE"
        blnFtpFinishFlag = True
        'MsgBox "upload finished"
                
        Exit Sub
        
    ErrorHandler:
        MsgBox "Error Number=" & Err.Number
        MsgBox "Error Source=" & Err.Source
        MsgBox "Error LastDllError=" & Err.LastDllError
        MsgBox "Error Description=" & Err.Description
        Err.Clear
    End Sub
      

  2.   

    偶遇过此问题,已有解决办法:    把长路径变成短路径即可。Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As LongFunction ShortName(LongPath As String) As String
        Dim ShortPath As String
        Const MAX_PATH = 260
        Dim ret&
        ShortPath = Space$(MAX_PATH)
        ret& = GetShortPathName(LongPath, ShortPath, MAX_PATH)
        If ret& Then
            ShortPath = StrConv(ShortPath, vbFromUnicode) 
            ShortName = LeftB$(ShortPath, ret&)
            ShortName = StrConv(ShortName, vbUnicode)    End If
    End Function