我想在VB中将5个文件的修改日期做比较,求最后一个修改文件,求高手怎样才能实现这个功能?
解决方案 »
- VB 数据库
- 关于日期字段查询问题!
- 为何我的mshflexgrid.clip读不出数据?
- 你好请问什么是LDAP,如何安装,win2000自带的协议吗?里面的OU=后面应该是填什么值
- VB数据库打印
- 套打发票时,发票高度为什么总是不能按预期的高度走纸,越来越套不上了!
- 急!急!有没有局域网内,服务器向多个客户机发数据的例子啊!
- 袁飞打印预览控件 2.0 版 升级! 下载有分!发言有分!使用有分!
- 求助!我在资源文件中有一张bmp图片,我想在程序运行时把它存在c:盘,怎么做到??
- 如何在access中添加新的数据
- 简单的数组问题 redim 后出现 Array Already Dimensioned
- vb写入的Txt文件为什么C#不能读
dim aDates(4) as date
dim i as long,j as long
...for i=0 to 4
aDates(i) = filedatetime(afiles(i))
if i=0 then
j = 0
elseif aDates(i) > aDates(j) then
j = i
end if
next
debug.print "last file is " & afiles(j) & ", datetime " & adates(j)
dim aFiles(4) as string
dim aDates(4) as date
dim i as long,j as longaFiles(0)="C\1.txt"
aFiles(1)="C\2.txt"
aFiles(2)="C\3.txt"
aFiles(3)="C\4.txt"for i=0 to 4
aDates(i) = FileDateTime(afiles(i))
if i=0 then
j = 0
elseif aDates(i) > aDates(j) then
j = i
end if
next i
debug.print "最后一个修改的文件为:" & afiles(j) & " | 修改时间为:" & adates(j)
Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Public Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, _
lpFindFileData As WIN32_FIND_DATA) _
As Long
Public Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Public Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" _
(ByVal lpFileName As String, _
lpFindFileData As WIN32_FIND_DATA) _
As LongType 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
Public 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 * MaxLFNPath
cShortFileName As String * 14
End Type
Public Function Findfile(xstrfilename) As WIN32_FIND_DATA
Dim Win32Data As WIN32_FIND_DATA
Dim plngFirstFileHwnd As Long
Dim plngRtn As Long
plngFirstFileHwnd = FindFirstFile(xstrfilename, Win32Data) ' Get information of file using API call
If plngFirstFileHwnd = 0 Then
Findfile.cFileName = "Error" ' If file was not found, return error as name
Else
Findfile = Win32Data ' Else return results
End If
plngRtn = FindClose(plngFirstFileHwnd) ' It is important that you close the handle for FindFirstFile
End Function
‘/////////////////////////////////
Dim tFileName As String
Dim FileData As WIN32_FIND_DATA
Dim fTime As SYSTEMTIME '//Initialise variables
tFileName = sPath '//File full path
FileData = Findfile(tFileName)
Call FileTimeToSystemTime(FileData.ftCreationTime, fTime)'//Determine Creation date and time,then format it
Call FileTimeToSystemTime(FileData.ftLastWriteTime, fTime)'//Determine Last Modified date and time
Call FileTimeToSystemTime(FileData.ftLastAccessTime, fTime)'//Determine Last accessed date (note no time is recorded)