Public Function Func_FTP(Operation,ServerName,UserName,Password,RemoteLocation,LocalLocation)

'Set up the environment
Const INTERNET_OPEN_TYPE_DIRECT = 1 Extern.Declare micLong, "InternetOpen", "wininet.dll", "InternetOpenA", micString, micDWord, micString, micString, micDWord Dim hInternet
hInternet = Extern.InternetOpen( "QTP_FTP", INTERNET_OPEN_TYPE_DIRECT, vbNullChar, vbNullChar, 0 ) If hInternet = 0 Then Func_FTP= False Reporter.ReportEvent micFail, "InternetOpen", "Failed to setup environment." Exit Function end If ' Open ftp server
Extern.Declare micLong, "InternetConnect", "wininet.dll", "InternetConnectA", micLong, micString, micInteger, micString, micString, micDWord, micDWord, micDWord Const INTERNET_DEFAULT_FTP_PORT = 22 Const INTERNET_SERVICE_FTP = 1 Dim hConnect hConnect = Extern.InternetConnect(hInternet,ServerName,INTERNET_DEFAULT_FTP_PORT,UserName,Password,INTERNET_SERVICE_FTP,0, 0 ) If hConnect = 0 Then Func_FTP= False Reporter.ReportEvent micFail, "InternetConnect", "Failed to open internet connection." Exit Function end If Dim bRetval Select case lcase(Operation) Case "getfile"
'Get file
Extern.Declare micInteger, "FtpGetFile", "wininet.dll", "FtpGetFileA", micLong, micString, micString, micInteger, micDWord, micDWord, micDWord Const FTP_TRANSFER_TYPE_ASCII = 1 bRetval = Extern.FtpGetFile( hConnect, RemoteLocation, LocalLocation, False, 0, FTP_TRANSFER_TYPE_ASCII, 0 ) wait(2) If Not CBool( bRetVal ) Then Func_FTP= False Reporter.ReportEvent micFail, "FtpGetFile " & RemoteLocation, "Failed to download file. at " & LocalLocation Exit Function end If Case "putfile"
'put file
Extern.Declare micInteger, "FtpPutFile", "wininet.dll", "FtpPutFileA", micLong, micString, micString, micDWord bRetval = Extern.FtpPutFile( hConnect,LocalLocation,RemoteLocation, 0 ) wait(2) If Not CBool( bRetVal ) Then Reporter.ReportEvent micFail, "FtpPutFile " & LocalLocation , "Failed to upload file. at " & RemoteLocation Func_FTP= False Exit Function End If Case "deletefile"
'delete file
Extern.Declare micInteger, "FtpDeleteFile", "wininet.dll", "FtpDeleteFileA",micLong,micstring bRetval =Extern.FtpDeleteFile(hConnect,RemoteLocation) wait(2) If Not CBool( bRetVal ) Then Reporter.ReportEvent micFail, "FtpPutFile", "Failed to delete file.--" & RemoteLocation Func_FTP= False Exit Function End If Case "findfile" Dim WIN32_FIND_DATA Extern.Declare micInteger, "FtpFindFirstFile", "wininet.dll", "FtpFindFirstFileA", micLong, micString,miclong, micDWord bRetval =Extern.FtpFindFirstFile(hConnect,RemoteLocation,WIN32_FIND_DATA,INTERNET_FLAG_NO_CACHE_WRITE) bRetval=left(bRetval,2) If bRetVal=0 Then Func_FTP= False Reporter.ReportEvent micFail, "File Not Found ", "File Not found ." Exit Function End If Case else End Select 'Close Connections
Extern.Declare micInteger, "InternetCloseHandle", "wininet.dll","InternetCloseHandle", micLong Extern.InternetCloseHandle( hConnect ) Extern.InternetCloseHandle( hInternet ) End Function

  

But  wininet.dll does't support sFTP

FTP- Download, upload, Delete & find files的更多相关文章

  1. C# show FTP Download/Upload progress

    https://stackoverflow.com/questions/4591059/download-file-from-ftp-with-progress-totalbytestoreceive ...

  2. Find and delete duplicate files

    作用:查找指定目录(一个或多个)及子目录下的所有重复文件,分组列出,并可手动选择或自动随机删除多余重复文件,每组重复文件仅保留一份.(支持文件名有空格,例如:"file  name" ...

  3. List or delete hidden files from command prompt(CMD)

    In Windows, files/folders have a special attribute called hidden attribute. By setting this attribut ...

  4. AVD Pixel_2_API_30 is already running. lf that is not the case, delete the files at

    AVD Pixel_2_API_30 is already running. lf that is not the case, delete the files at C:\Users\Adminis ...

  5. jquery ajax发送delete(use in jquery file upload delete file)

    环境: jQuery file upload HTML example code <div class="pic-preview"> <div class=&qu ...

  6. FTP Download File By Some Order List

    @Echo Off REM -- Define File Filter, i.e. files with extension .RBSet FindStrArgs=/E /C:".asp&q ...

  7. python ftp download with progressbar

    i am a new one to learn Python. Try to download by FTP. search basic code from baidu. no one tells h ...

  8. [Powershell] FTP Download File

    # Config $today = Get-Date -UFormat "%Y%m%d" $LogFilePath = "d:\ftpLog_$today.txt&quo ...

  9. Atitit s2018.5 s5 doc list on com pc.docx  v2

    Atitit s2018.5 s5  doc list on com pc.docx  Acc  112237553.docx Acc Acc  112237553.docx Acc baidu ne ...

随机推荐

  1. k8s 组件介绍-kube-schedule

    kubernetes scheduler 基本原理 kubernetes scheduler 作为一个单独的进程部署在 master 节点上,它会 watch kube-apiserver 进程去发现 ...

  2. mintUI修改toast样式的问题解决办法

    在公共样式中加入 /*修改mintUI 弹窗样式大小*/ .noticeErrorToast{ transform: scale(2) !important; margin-left:-.6rem ! ...

  3. C#设计模式:组合模式(Composite Pattern)

    一,C#设计模式:组合模式(Composite Pattern) using System; using System.Collections.Generic; using System.Linq; ...

  4. NGUI多行输入框和滚动条结合使用(text list script 和scroll bar script)

    一,我们添加一个label,如下图:将label属性设置 二,给label添加一个box collider.然后在add component 添加test list,如下图: 三,添加一个脚本Test ...

  5. 搭建阿里云服务器(centos,jdk和Tomcat版本)

    1.购买服务器(登录阿里云,购买服务器,并进入控制台,查看自己的服务器实例 2.域名注册(这步可以省略,直接IP地址访问,因为域名需要备案),购买域名的需要进行解析以及绑定自己的服务器 3.可以准备一 ...

  6. A星寻路

    逻辑代码 using System.Collections.Generic; using System.Text; using UnityEngine; namespace Game { public ...

  7. source insight 4.0.86.0安装破解问题

    source insight 4.0.86.0安装过程中碰到导入lic文件一直不正确 解决办法: 需要将SourceInsight\SW_Install\SI4安装及破解文件 目录下的sourcein ...

  8. SDOI2018凉凉记

    好久没有更博客了...因为我在颓废学习.. SDOI一轮结束了...我也该回来学地生了... 凉凉 ————————————————我是分割线———————————————— Day0 愉快感冒的Da ...

  9. Ubuntu14.04安装Ruby2.2方法

    直接使用系统的sudo apt-get install ruby2.0安装后,ruby -v显示ruby的版本依然是ruby 1.9. 以下方法可以顺序地在Ubuntu14.04安装Ruby2.2 s ...

  10. springMVC的controller更改了,如何不重启,而自动刷新的解决办法(亲测,一招解决)

    Tomcat  con/ service.xml  配置如下一行代码: <Context reloadable="true"/> </Host> 然后以de ...