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 ...
随机推荐
- dp(过河问题)
http://codeforces.com/gym/101492/problem/E Teamwork is highly valued in the ACM ICPC. Since the begi ...
- 13、numpy——算术函数
NumPy 算术函数 1.NumPy 算术函数包含简单的加减乘除: add(),subtract(),multiply() 和 divide(). 需要注意的是数组必须具有相同的形状或符合数组广播规则 ...
- rpmdeps - 生成 RPM 软件包依赖关系
SYNOPSIS rpmdeps {-P|--provides} {-R|--requires} FILE ... DESCRIPTION rpmdeps 根据 FILE 参数集合,生成软件包依赖关系 ...
- Nginx学习总结:geo与image模块(四
斜体下划线,表示建议采用默认配置,无需显式的配置 一.ngx_http_geo_module 核心特性为:根据客户端IP(段),geo模块将会匹配出指定的变量(比如,国家代码,城市代码).geo模块可 ...
- 246-基于TI DSP TMS320C6678、Altera FPGA的CPCI处理卡
基于TI DSP TMS320C6678.Altera FPGA的CPCI处理卡 1.板卡概述 本板卡由我公司自主研发,基于CPCI架构,符合CPCI2.0标准,采用两片TI DSP TMS320C ...
- django 常用 import
from django.shortcuts import HttpResponse, render, redirect def yimi(request): #直接返回页面内容 return Http ...
- 没有dockerfile的情况下如何查看docker的镜像信息
前言 参考资料 https://baijiahao.baidu.com/s?id=1564406878758073&wfr=spider&for=pc 很实用的功能哈.. 步骤 1.先 ...
- Debian取消从光盘安装软件的方式(please insert the disc labeled)
与Ubuntu不同,使用apt-get install packages时Debian可能会提示: Media change: please insert the disc labeled 'Debi ...
- java获取当前月第一天和最后一天
获取当前月第一天: /** * 获取当前月第一天 * @param month * @return */ public static String getFirstDayOfMonth(int mon ...
- 【leetcode】1018. Binary Prefix Divisible By 5
题目如下: Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted a ...