用FtpFindFirstFile,InternetFindNextFile 这两个函数
FtpFindFirstFile 返回文件信息。放在 WIN32_FIND_DATA 结构中
InternetFindNextFile 调用 FtpFindFirstFile()后在目录中连续查找
当找到FTP服务器上的一个文件时,可获得该文件的最后一次修改时间
函数的声明是:
Private Declare Function FtpFindFirstFile Lib "wininetdll" Alias "FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As String,lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long,ByVal dwContent As Long) As LongPrivate Declare Function InternetFindNextFile Lib "wininetdll" Alias "InternetFindNextFileA" (ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long
还需定义一个数据类型:WIN32_FIND_DATA,用于保存相关路径下的文件的信息。类型结构如下:
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String MAX_PATH
cAlternate As String 14
End Type
ftLastWriteTime就是最后的修改时间
例:
FtpFindFirstFile(FTP连接句柄,需要知道日期的文件名,WIN32_FIND_DATA格式的变量,2,0);
API函数FileTimeToSystemTime可以将FILETIME转换为系统时间结构SYSTEMTIME
Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
echo open ip>a
set datenum=%date:~5,2%%date:~8,2%
echo user>>a
echo password>>a
echo bin>>a
echo get aaa%datenum%txt>>a
echo bye>>a
ftp -s:a
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)