查看: 299  |  回复: 0
ASP 删除修改日期超过5天(5天前的历史文件/文件夹)的文件和子文件夹
楼主
发表于 2023年5月24日 16:19
<%
Const strPath = "D:\manongku\txt"
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Call Search(strPath)

Response.Write "清理完毕!"

Sub Search(str)
    Dim objFolder, objSubFolder, objFile
    Set objFolder = objFSO.GetFolder(str)
    For Each objFile In objFolder.Files
        If objFile.DateLastModified < (Now() - 5) Then  '五天前的记录
            objFile.Delete (True)
        End If
    Next

    For Each objSubFolder In objFolder.SubFolders
        Search (objSubFolder.Path)
        ' 文件都清理了,现在看看
        ' 文件夹是否空的。
        If (objSubFolder.Files.Count = 0) Then
            objSubFolder.Delete True
        End If
    Next
End Sub
%>


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com