我正在尝试准备一个VB脚本,可以将文件复制到我的客户端的服务器上,但不能在脚本中使用昂贵的第三方FTP组件。
行可能存在问题" objFTP.CopyHere objItem,copyType"但我不知道如何解决这个问题。有什么想法吗?
这是我的代码:
Set oShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
path = "D:\test\"
FTPUpload(path)
Sub FTPUpload(path)
'On Error Resume Next
Const copyType = 16
'FTP Wait Time in ms
waitTime = 80000
FTPUser = "xxxxx"
FTPPass = "xxxxxx"
FTPHost = "xxxx.xxx"
FTPDir = "/public_html/testfolder/"
strFTP = "ftp://" & FTPUser & ":" & FTPPass & "@" & FTPHost & FTPDir
Set objFTP = oShell.NameSpace(strFTP)
MsgBox strFTP
'Upload single file
ufile = path & "bappy.txt"
If objFSO.FileExists(ufile) Then
Set objFile = objFSO.getFile(ufile)
strParent = objFile.ParentFolder
Set objFolder = oShell.NameSpace(strParent)
Set objItem = objFolder.ParseName(objFile.Name)
Wscript.Echo "Uploading file " & objItem.Name & " to " & strFTP
objFTP.CopyHere objItem, copyType
End If
If Err.Number <> 0 Then
Wscript.Echo "Error: " & Err.Description
End If
'Wait for upload
Wscript.Sleep waitTime
End Sub