51Testing软件测试论坛

标题: QTP如何上传文件到FTP [打印本页]

作者: haihai1005    时间: 2010-5-11 13:17
标题: QTP如何上传文件到FTP
各位:
   QTP如何将文件上传到FTP上面
作者: TIB    时间: 2010-5-11 14:29
  1. Const DEFAULT_FTP_PORT =21
  2. Const SERVICE_FTP = 1
  3. Const OPEN_TYPE_DIRECT = 1
  4. Const FTP_TRANSFER_TYPE_ASCII = 1

  5. Extern.Declare micLong,"InternetOpen","wininet.dll","InternetOpenA",micString,micDWord,micString,micString,micDWord
  6. Extern.Declare micLong,"InternetConnect","wininet.dll","InternetConnectA",micLong,micString,micInteger,micString,micString,micDWord,micDWord,micDWord
  7. Extern.Declare micInteger,"FtpGetFile","wininet.dll","FtpGetFileA",micLong,micString,micString,micInteger,micDWord,micDWord,micDWord
  8. Extern.Declare micInteger,"FtpPutFile","wininet.dll","FtpPutFileA",micLong,micString,micString,micDWord
  9. Extern.Declare micInteger,"InternetCloseHandle","wininet.dll","InternetCloseHandle",micLong

  10. '  打开
  11. hInternet = Extern.InternetOpen("QTP_FTP",OPEN_TYPE_DIRECT,vbNullChar,vbNullChar,0)
  12. If hInternet=0 Then Print("QTP_FTP:Failed to setup FTP environment.")

  13. ' 连接
  14. hConnection = Extern.InternetConnect(hInternet,"www.atstudy.com",DEFAULT_FTP_PORT,"user1","user1",1,0,0)
  15. If hConnection =0 Then Print("Failed to setup FTP environment")

  16. ' 上传
  17. ' bRetval = Extern.FtpPutFile(hConnection,sLocalFile,sRemoteFile,0)

  18. ' 下载
  19. bRetval = Extern.FtpGetFile(hConnection,"/Mercury/QuickTest/QTP crack.rar","D:\QTP crack.rar",0,0,1,0)
  20. If Not CBool(bRetVal) Then
  21.         Reporter.ReportEvent micFail,"FTP:FtpGetFile function","Failed to open download file."
  22. else
  23.         Print("FTP:File :QTP crack.rar downloaded successfully")
  24.         'Reporter.ReportEvent micPass,"FTP:FtpPutFile function","FTP:File"&sLocalFile&"upload successfully."
  25. End If

  26. ' 关闭
  27. Extern.InternetCloseHandle(hConnection)
  28. Extern.InternetCloseHandle(hInternet)
复制代码

作者: haihai1005    时间: 2010-5-13 09:58
谢谢楼上的 你帮了我大忙




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2