DateCreated属性
返回指定文件或文件夹的创建日期和时间。
只读。
应用于File对象,Folder对象语法object.DateCreatedobject总是一个file或Folder对象。
说明下面的代码用一个文件举例说明了DateCreated属性的用法:
Sub ShowFileInfo(filespec)
Dim fs,f,s
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(filespec) s="Created:"&f.DateCreated
MsgBox s
End Sub
返回指定文件或文件夹的创建日期和时间。
只读。
应用于File对象,Folder对象语法object.DateCreatedobject总是一个file或Folder对象。
说明下面的代码用一个文件举例说明了DateCreated属性的用法:
Sub ShowFileInfo(filespec)
Dim fs,f,s
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(filespec) s="Created:"&f.DateCreated
MsgBox s
End Sub
(ByVal lpFileName As String, _
lpFindFileData As WIN32_FIND_DATA _
) As Long
Private Declare Function FindClose Lib "kernel32" _
(ByVal hFindFile As Long _
) As Long
Private Declare Function FileTimeToSystemTime Lib "kernel32" _
(lpFileTime As FILETIME, _
lpSystemTime As SYSTEMTIME _
) As Long
Private Declare Function GetSystemTimeAsFileTime Lib "kernel32" _
(lpFileTime As FILETIME)
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)Private Const FILE_ATTRIBUTE_READONLY = &H1
Private Const FILE_ATTRIBUTE_HIDDEN = &H2
Private Const FILE_ATTRIBUTE_SYSTEM = &H4
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const FILE_ATTRIBUTE_TEMPORARY = &H100
Private Const FILE_ATTRIBUTE_COMPRESSED = &H800
'
Private Type FILETIME
LowDateTime As Long
HighDateTime As Long
End Type
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 * 260 'MUST be set to 260
cAlternate As String * 14
End Type
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
'
Private 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'---------------------------------------------------------------
'---读文件的最后修改时间
'---------------------------------------------------------------
Private Function fFileDate(vFileName As String) As String
On Error GoTo ErrHandle
Dim ftime As SYSTEMTIME ' Initialise variables
Dim tfilename As String
Dim filedata As WIN32_FIND_DATA
Dim tTemp As String
'
filedata = Findfile(vFileName)
Call FileTimeToSystemTime(filedata.ftLastWriteTime, ftime)
GetLocalTime ftime
tTemp = ftime.wDay & "/" & ftime.wMonth & "/" & ftime.wYear & " " _
& ftime.wHour & ":" & ftime.wMinute & ":" & ftime.wSecond
fFileDate = Format(tTemp, "yyyy-mm-dd hh:mm:ss")
Exit Function
ErrHandle:
fFileDate = "1980-01-01 00:00:00"
End Function
Private Sub Command1_Click()
MsgBox fFileDate("c:\unzipped\docs\documentation.doc")
End Sub
返回最后一次访问指定文件或文件夹的日期和时间。只读。
应用于
File对象,Folder对象
语法
object.DateLastAccessedobject总是一个file或Folder对象。
说明
下面的代码用一个文件举例说明了DateLastAccessed属性的用法:SubShowFileAccessInfo(filespec)
Dim fs,f,s
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(filespec)
s=UCase(filespec)&vbCrLf
s=s&"Created:"&f.DateCreated&vbCrLf
s=s&"LastAccessed:"&f.DateLastAccessed&vbCrLf
s=s&"LastModified:"&f.DateLastModified
MsgBox s,0,"FileAccessInfo"
EndSub
重点这种方法由其下一级操作系统决定其行为。
返回最后一次访问指定文件或文件夹的日期和时间。只读。
应用于
File对象,Folder对象
语法
object.DateLastAccessedobject总是一个file或Folder对象。
说明
下面的代码用一个文件举例说明了DateLastAccessed属性的用法:SubShowFileAccessInfo(filespec)
Dim fs,f,s
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(filespec)
s=UCase(filespec)&vbCrLf
s=s&"Created:"&f.DateCreated&vbCrLf
s=s&"LastAccessed:"&f.DateLastAccessed&vbCrLf
s=s&"LastModified:"&f.DateLastModified
MsgBox s,0,"FileAccessInfo"
EndSub
重点这种方法由其下一级操作系统决定其行为。
GetFileTime【操作系统】
Win9X:Yes
WinNT:Yes【声明】
GetFileTime Lib "kernel32" Alias "GetFileTime" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long【说明】 取得指定文件的时间信息 【返回值】 Long,非零表示成功,零表示失败。会设置GetLastError 【其它】 如果不需要特定的信息,那么lpCreationTime,lpLastAccessTime,lpLastWriteTime都可以设置为零(用ByVal
As Long)。这个函数返回的文件时间采用UTC格式【参数表】
hFile ---------- Long,文件的句柄 lpCreationTime - FILETIME,用于装载文件的创建时间 lpLastAccessTime - FILETIME,用于装载文件上一次访问的时间(FAT文件系统不支持这一特性) lpLastWriteTime - FILETIME,用于装载文件上一次修改的时间
引用袁飞的API数据库
Shell "cmd.exe /k dir C:\ /ad > DirInfo.txt" 驱动器 C 中的卷是 WIN98
卷的序列号是 4362-12E8 C:\ 的目录2001-10-13 11:28 <DIR> WINDOWS
2001-10-13 13:20 <DIR> RECYCLED
2002-06-24 15:22 <DIR> 切换
2001-10-13 11:28 <DIR> Program Files
2001-10-13 11:56 <DIR> My Documents
2002-06-25 14:18 <DIR> 麻辣鲜师
2002-07-09 12:01 <DIR> scebeta
2002-05-21 09:18 <DIR> !WNM
2001-12-05 12:46 <DIR> w2k files
2002-03-13 14:07 <DIR> jdk1.3.0_01
2002-07-09 16:29 <DIR> test
2002-04-28 08:33 <DIR> RealPlayer
2002-05-21 11:17 <DIR> FreeICQ
2002-06-26 11:26 <DIR> foxmail
2002-06-26 16:53 <DIR> csdn
2002-06-18 09:41 <DIR> Apache
2002-06-27 11:52 <DIR> Perl
2002-06-24 08:49 <DIR> Zip
2002-06-24 08:47 <DIR> 脚本编程帮助
2001-10-24 09:06 <DIR> KRECYCLE
2002-07-02 17:04 <DIR> bcpd_detail_sort4511
2002-05-10 10:55 <DIR> Macromedia
2002-05-27 09:41 <DIR> 红蜻蜓
2002-06-07 08:53 <DIR> RAVBIN
0 个文件 0 字节
25 个目录 3,258,413,056 可用字节然后在文件里查找你要的目录的时间,比如你要找C:\Windows,就找
"<DIR> WINDOWS" 所在的行,然后把行首的日期读出来!
返回最后一次修改指定文件或文件夹的日期和时间。只读。
应用于
File对象,Folder对象
语法
object.DateLastModifiedobject总是一个file或Folder对象。
说明
下面的代码用一个文件举例说明了DateLastModified属性的用法:SubShowFileAccessInfo(filespec)
Dimfs,f,s
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(filespec)
s=UCase(filespec)&vbCrLf
s=s&"Created:"&f.DateCreated&vbCrLf
s=s&"LastAccessed:"&f.DateLastAccessed&vbCrLf
s=s&"LastModified:"&f.DateLastModified
MsgBox s,0,"FileAccessInfo"
EndSub
返回最后一次修改指定文件或文件夹的日期和时间。只读。
应用于
File对象,Folder对象
语法
object.DateLastModifiedobject总是一个file或Folder对象。
说明
下面的代码用一个文件举例说明了DateLastModified属性的用法:SubShowFileAccessInfo(filespec)
Dimfs,f,s
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(filespec)
s=UCase(filespec)&vbCrLf
s=s&"Created:"&f.DateCreated&vbCrLf
s=s&"LastAccessed:"&f.DateLastAccessed&vbCrLf
s=s&"LastModified:"&f.DateLastModified
MsgBox s,0,"FileAccessInfo"
EndSub
Shell "cmd.exe /k dir C:\ /ad > DirInfo.txt" 驱动器 C 中的卷是 WIN98
卷的序列号是 4362-12E8 C:\ 的目录2001-10-13 11:28 <DIR> WINDOWS
2001-10-13 13:20 <DIR> RECYCLED
2002-06-24 15:22 <DIR> 切换
2001-10-13 11:28 <DIR> Program Files
2001-10-13 11:56 <DIR> My Documents
2002-06-25 14:18 <DIR> 麻辣鲜师
2002-07-09 12:01 <DIR> scebeta
2002-05-21 09:18 <DIR> !WNM
2001-12-05 12:46 <DIR> w2k files
2002-03-13 14:07 <DIR> jdk1.3.0_01
2002-07-09 16:29 <DIR> test
2002-04-28 08:33 <DIR> RealPlayer
2002-05-21 11:17 <DIR> FreeICQ
2002-06-26 11:26 <DIR> foxmail
2002-06-26 16:53 <DIR> csdn
2002-06-18 09:41 <DIR> Apache
2002-06-27 11:52 <DIR> Perl
2002-06-24 08:49 <DIR> Zip
2002-06-24 08:47 <DIR> 脚本编程帮助
2001-10-24 09:06 <DIR> KRECYCLE
2002-07-02 17:04 <DIR> bcpd_detail_sort4511
2002-05-10 10:55 <DIR> Macromedia
2002-05-27 09:41 <DIR> 红蜻蜓
2002-06-07 08:53 <DIR> RAVBIN
0 个文件 0 字节
25 个目录 3,258,413,056 可用字节然后在文件里查找你要的目录的时间,比如你要找C:\Windows,就找
"<DIR> WINDOWS" 所在的行,然后把行首的日期读出来!
返回最后一次修改指定文件或文件夹的日期和时间。只读。
应用于
File对象,Folder对象
语法
object.DateLastModifiedobject总是一个file或Folder对象。
说明
下面的代码用一个文件举例说明了DateLastModified属性的用法:SubShowFileAccessInfo(filespec)
Dimfs,f,s
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile(filespec)
s=UCase(filespec)&vbCrLf
s=s&"Created:"&f.DateCreated&vbCrLf
s=s&"LastAccessed:"&f.DateLastAccessed&vbCrLf
s=s&"LastModified:"&f.DateLastModified
MsgBox s,0,"FileAccessInfo"
EndSub
Private Sub Command1_Click()ShowFileInfo "C:\windows\"
ShowFileInfo2 "C:\windows\"
End SubSub ShowFileInfo(filespec As String)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.Getfolder(filespec)
s = "Created:" & f.DateCreated
MsgBox s
End SubSub ShowFileInfo2(filespec As String)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.Getfolder(filespec)
s = UCase(filespec) & vbCrLf
s = s & "Created:" & f.DateCreated & vbCrLf
s = s & "LastAccessed:" & f.DateLastAccessed & vbCrLf
s = s & "LastModified:" & f.DateLastModified
MsgBox s, 0, "FileAccessInfo"
End Sub
谢谢参与..