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 ...
随机推荐
- Codeforces 1093D(染色+组合数学)
题面 传送门 题目大意:给出一个无向图,每个节点可以填1,2,3三个数中的一个 问有多少种填数方案,使两个相邻节点的数之和为奇数 分析 如果图中有奇环,一定无解 我们对图黑白染色,由于图可能不联通,记 ...
- 点分治题单(来自XZY)
点分治题单(来自XZY) 静态点分治 [x] 洛谷 P3806 [模板]点分治1 [x] 洛谷 P4178 Tree [x] 洛谷 P2634 [国家集训队]聪聪可可 [x] 洛谷 P4149 [IO ...
- luoguP3391[模板]文艺平衡树(Splay) 题解
链接一下题目:luoguP3391[模板]文艺平衡树(Splay) 平衡树解析 这里的Splay维护的显然不再是权值排序 现在按照的是序列中的编号排序(不过在这道题目里面就是权值诶...) 那么,继续 ...
- [fw]Die 為什麼不能用現在完成式?
have PP是表示"從以前到現在"都直在做的事情 Mr. Chen has taught English for 30 years.---表示teach的動作持續了30年,但Mr ...
- Codeforces Round #529 (Div. 3) E. Almost Regular Bracket Sequence (思维)
Codeforces Round #529 (Div. 3) 题目传送门 题意: 给你由左右括号组成的字符串,问你有多少处括号翻转过来是合法的序列 思路: 这么考虑: 如果是左括号 1)整个序列左括号 ...
- P5468 [NOI2019]回家路线
传送门 看题目一眼斜率优化,然后写半天调不出来 结果错误的 $dfs$ 有 $95$ 分?暴力 $SPFA$ 就 $AC$ 了? 讲讲正解: 显然是斜率优化的式子: 先不考虑 $q_{s_k}$ 的贡 ...
- linux 日常学习
杀掉进程 ps aux |grep caddy axy5418+ 14186 0.0 1.7 117032 10372 ? Sl 02:17 0:00 caddy axy5418+ 14332 0.0 ...
- JVM分为哪些区,每一个区干嘛的?
程序计数器PC 线程私有的 它可以看做是当前线程所执行的字节码的行号指示器 内存区域中唯一一个没有规定任何OutOfMemoryError的区域 Java虚拟机栈 线程私有的 每个方法在执行的同时都会 ...
- 【Leetcode周赛】从contest-111开始。(一般是10个contest写一篇文章)
Contest 111 (题号941-944)(2019年1月19日,补充题解,主要是943题) 链接:https://leetcode.com/contest/weekly-contest-111 ...
- STREAM Benchmark及其操作性能分析
STREAM 是业界广为流行的综合性内存带宽实际性能 测量 工具之一.随着处理器处理核心数量的增多,内存带宽对于提升整个系统性能越发重要,如果某个系统不能够足够迅速地将内存中的数据传输到处理器当中,若 ...