FTP- Download, upload, Delete & find files
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的更多相关文章
- C# show FTP Download/Upload progress
https://stackoverflow.com/questions/4591059/download-file-from-ftp-with-progress-totalbytestoreceive ...
- Find and delete duplicate files
作用:查找指定目录(一个或多个)及子目录下的所有重复文件,分组列出,并可手动选择或自动随机删除多余重复文件,每组重复文件仅保留一份.(支持文件名有空格,例如:"file name" ...
- List or delete hidden files from command prompt(CMD)
In Windows, files/folders have a special attribute called hidden attribute. By setting this attribut ...
- 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 ...
- jquery ajax发送delete(use in jquery file upload delete file)
环境: jQuery file upload HTML example code <div class="pic-preview"> <div class=&qu ...
- FTP Download File By Some Order List
@Echo Off REM -- Define File Filter, i.e. files with extension .RBSet FindStrArgs=/E /C:".asp&q ...
- 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 ...
- [Powershell] FTP Download File
# Config $today = Get-Date -UFormat "%Y%m%d" $LogFilePath = "d:\ftpLog_$today.txt&quo ...
- 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 ...
随机推荐
- java中位运算和移位运算详解
一.位运算 (1)按 位 与 & 如果两个相应的二进制形式的对应的位数都为1,则结果为1,记为同1为1,否则为0.首先我们看一下对正数的运算 分别看一下正数和负数的具体运算步骤 ...
- swiper轮播图设置每组显示的个数及自定义slide宽度
一.html演示代码: <div class="swiper-container"> <div class="swiper-wrapper"& ...
- Kvm --05 密码保护:Kvm管理之WebVirtMgr
目录 密码保护:Kvm管理之WebVirtMgr 1. 前言 2. 特点 3. 功能 4. 部署 1).安装相关依赖 2).安装Python需求环境 3).配置Nginx 4). 远程连接 5).更新 ...
- MYSQL5.7版本sql_mode=only_full_group_by问题,重启有效的方法
1./etc/mysql/mysql.conf.d/mysqld.cnf 或者my.cnf 总之就是mysql的配置文件 2.查看当前的sql模式 select @@sql_mode; 3.添加语 ...
- VisualVM监控远程主机
参考博客 https://blog.csdn.net/u010004317/article/details/82948040 https://blog.csdn.net/lienfeng6/artic ...
- better-scroll 的使用
1.安装 cnpm install better-scroll --save 2.引入 import BScroll from "better-scroll"; 3.初始化 dat ...
- 磁盘I/O工作原理
原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11524947.html TODO Reference https://time.geekbang.or ...
- 浅谈SAP CRM和Hybris Commerce里的价格架构折扣
最近Jerry做了一个和价格折扣相关的原型项目,把学到的知识记录下来,以备将来查阅. 在这个原型项目里,我们用React-Native开发了一个移动应用,用户可以在手机上浏览SAP Hybris Co ...
- centos6.8安装tomcat多容器的处理办法,及安装zk、dubbo
系统环境: Linux-centosOS6.8-bit64 JDK1.8 1.Tomcat多容器的处理方案 首先,不论tomcat的版本是否有多个,路径是否相同,肯定的是可以运行多个容器. 处理以下两 ...
- js 属性getset
属性访问器 一.像C#写实体类一样的写法 var attr={ $x:10,//必须$开头 get x() { return this.$x+1; }, set x(val) { this.$x=va ...