Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

【access小品】删除备份文件函数

时 间:2010-08-06 06:29:26
作 者:todaynew   ID:10802  城市:武汉
摘 要:删除文件
正 文:

Public Function DelFiles(FldPath As String, Mydate As Date, str As String)
'引用:Microsoft Scripting Runtime
'功能:删除备份文件
'参数:FldPath--文件夹地址; Mydate--删除文件的创建日期范围; str--备份文件的扩展名
'示例:DelFiles CurrentProject.Path, DateAdd("d", -1, Date), "bak"
Dim FSO As New FileSystemObject
Dim Fld As Folder
Dim Fil As File

If FSO.FolderExists(FldPath) = True Then
    Set Fld = FSO.GetFolder(FldPath)
    For Each Fil In Fld.Files
        If Mid(Fil.Name, InStrRev(Fil.Name, ".") + 1) = str Then
            If Format(Fil.DateLastModified, "yyyy/mm/dd") <= Format(Mydate, "yyyy/mm/dd") Then
                FSO.DeleteFile Fil.Path
            End If
        End If
    Next Fil
End If
Set Fil = Nothing
Set Fld = Nothing
Set FSO = Nothing
End Function



Access软件网QQ交流群 (群号:483923997)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助