我的代码是这样写的,
function ftpsend()
Dim vPath As String
Dim vFile As String
Dim vFTPServ As String
Dim fNum As Long
Dim currntdir As String
currntdir = ThisWorkbook.Path & "\"
vPath = currntdir
vFile = currntdir & "abc.xml"
vFTPServ = "ftp.abc.com"
'Mounting file command for ftp.exe
fNum = FreeFile()
Open vPath & "abc.txt" For Output As #fNum
Print #1, "USER student"
Print #1, "xxxxx"
Print #1, "send " & vFile
Print #1, "close"
Print #1, "quit"
Close
Shell "ftp -n -i -g -s:" & vPath & "abc.txt " & vFTPServ, vbNormalFocus
end function
现在,shell 命令在控制台 ftp.exe 中将输出显示为
Connected to ftp.abc.com
220 Microsoft FTP service
ftp>USER student
230 User logged in
ftp>send D:abc.xml
200 PORT command successful
226 Transfer Complete
ftp>close
221>Good bye
ftp>
我想要控制台的这个输出,因为它被复制到一个文本文件中。因为,有时当用户名和密码不正确时,它会在控制台中显示消息为“用户未登录”,“登录失败”。我想处理那个错误。还有其他方法来处理 ftp 错误吗?请帮忙...
提前致谢