风管清洗方案:ftp上传如何能传到指定目录里

来源:百度文库 编辑:中科新闻网 时间:2024/05/09 12:46:15
如何才能传到指定目录里,我一上传就传到根目录下了
请高手指点

Public Function SendFiles() As Integer
Dim i As Integer
Dim colFileInfo As Collection
Dim iSentOk As Integer
Dim bPortOk As Boolean
Dim sRemote As String
Dim sLocal As String

If msServerName = "" Or msUsername = "" Then
SendFiles = -1
Exit Function
End If

If EstablishConnection() Then

For Each colFileInfo In mclnFilesToSend

bPortOk = False

Do

bPortOk = EstablishPort()

If Not bPortOk Then

Debug.Print "重建连接..."

If Not EstablishConnection() Then
Debug.Print "Failed to re-establish connection"
RaiseEvent StatusUpdate("没有连接上", glSETError)
Exit Function
End If

End If

Loop While Not bPortOk

RaiseEvent StatusUpdate("开始上传文件...", glSETInfo)

sRemote = colFileInfo.Item("Remote")
sLocal = colFileInfo.Item("Local")

If SendFile(sRemote, sLocal) Then
iSentOk = iSentOk + 1
End If

wskRead.Close

If Not WaitFor("226", False) Then
RaiseEvent StatusUpdate("对不起,上传没有成功!", glSETError)
End If

Next

wskWrite.Close

RaiseEvent StatusUpdate(iSentOk & " 个文件上传成功!", glSETInfo)
SendFiles = iSentOk

End If

'cleanup
ClearAllFiles

End Function
Private Function EstablishPort() As Boolean
sIPAddr = wskWrite.LocalIP
Do Until InStr(sIPAddr, ".") = 0 ' replace every "." in sIPAddr With a ","
sIPAddr = Mid(sIPAddr, 1, InStr(sIPAddr, ".") - 1) & "," & Mid(sIPAddr, InStr(sIPAddr, ".") + 1)
Loop
Debug.Print "PORT " & sIPAddr.ftpmenu & "," & Trim(Str(lRandNo1)) & "," & Trim(Str(lRandNo2))
wskWrite.SendData "PORT " & sIPAddr & "," & Trim(Str(lRandNo1)) & "," & Trim(Str(lRandNo2)) & vbCrLf 'Tell the server With which sIPAddr he has to connect and with which port
bPortOk = WaitFor("200", False)
If bPortOk Then
wskRead.Close
wskRead.LocalPort = lRandNo1 * 256 Or lRandNo2 ' Set port of second winsock-control to the port the server will connect to
Debug.Print "LocalPort = " & wskRead.LocalPort
wskRead.Listen
EstablishPort = True
End If
End Function

我不知道是不是这段代码,请高手能给个完整代码谢谢~