'»ñÈ¡ÎļþÐÅÏ¢µÄ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
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
'获取文件信息的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
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
'»ñÈ¡ÎļþÐÅÏ¢µÄ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
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