技術(shù) 點(diǎn)
- 技術(shù)
- 點(diǎn)
- V幣
- 點(diǎn)
- 積分
- 2899
|
2#
發(fā)表于 2009-12-12 17:20:10
|
只看該作者
Option Compare Database
'»ñÈ¡ÎļþÐÅÏ¢µÄGetFileInfoº¯Êý
Type FileInfo
FileName As String 'Ãû×Ö
ShortName As String
Type As String 'ÀàÐÍ
Size As Long
DateCreate As Date
DateLastModified As Date '
DateLastAccessed As Date
Attributes As String
End Type
'===============================================================================
'-º¯ÊýÃû³Æ: GetFileInfo
'-¹¦ÄÜÃèÊö: »ñÈ¡ÎļþÐÅÏ¢
'-ÊäÈë²ÎÊý˵Ã÷: ²ÎÊý1: ±ØÑ¡ strFile As String Îļþ·¾¶ºÍÃû³Æ
'-·µ»Ø²ÎÊý˵Ã÷: ·µ»ØÎļþÃû³Æ£¬ÀàÐÍ£¬´óС£¬¸üÐÂÈÕÆÚµÈ
'-ʹÓÃÓ﷨ʾÀý: Msgbox GetFileInfo("C:\Abc.txt").Size
'-ÒýÓÃ:Microsoft Scripting Runtime
'===============================================================================
Function GetFileInfo(strFile As String) As FileInfo
On Error Resume Next
Dim fsoSys As New Scripting.FileSystemObject
Dim fsoFile As File
Dim strstrastr As String
Set fsoFile = fsoSys.GetFile(strFile)
With GetFileInfo
.FileName = fsoFile.Name
.ShortName = fsoFile.ShortName
.Type = fsoFile.Type
.Size = fsoFile.Size / 1000
.DateCreate = fsoFile.DateCreated
.DateLastModified = fsoFile.DateLastModified
.DateLastAccessed = fsoFile.DateLastAccessed
If fsoFile.Attributes And Archive Then
strAstr = strAstr & "³£¹æ "
End If
If fsoFile.Attributes And ReadOnly Then
strAstr = strAstr & "Ö»¶Á "
End If
If fsoFile.Attributes And Hidden Then
strAstr = strAstr & "Òþ²Ø "
End If
' If fsoFile.Attributes And System Then 'ÕâÒ»¾äÓÐÎÊÌ⣬Ìáʾsystem䶨Òå
If fsoFile.Attributes And 4 Then
strAstr = strAstr & "ϵͳ "
End If
If fsoFile.Attributes And Compressed Then
strAstr = strAstr & "ѹËõ "
End If
.Attributes = strAstr
End With
Set fsoSys = Nothing
Set fsoFile = Nothing
End Function |
|