[荐]获取文件信息的函数
时 间:2008-07-07 09:58:46
作 者:fan0217 ID:8 城市:上海 QQ:2851379730
摘 要:在ACCESS爱好者论坛(http://www.accfans.net)看到fan0217版主提供的一个函数,推荐给大家!
正 文:
一、原文地址
在:http://www.accfans.net/dispbbs.asp?boardID=21&ID=15882&page=1
二、模块代码:
Type FileInfo
Name 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
'-兼容性: 2000,XP,2003
'-作者: fan0217@163.com
'-更新日期: 2006-05-20
'===============================================================================
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
.Name = 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
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
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- 仓库管理实战课程(8)-商品信息功...(04.01)
- 仓库管理实战课程(7)-链接表(03.31)
- 仓库管理实战课程(6)-创建查询(03.29)
- 仓库管理实战课程(5)-字段属性(03.27)
- 设备装配出入库管理系统;基于Acc...(03.24)
- 仓库管理实战课程(4)-建表操作(03.22)
- 仓库管理实战课程(3)-需求设计说...(03.19)
- 仓库管理实战课程(2)-软件背景和...(03.18)
- 仓库管理实战课程(1)-讲师介绍(03.16)
- 统计当月之前(不含当月)的记录数怎...(03.11)