zoukankan      html  css  js  c++  java
  • [VBScript] 自动删除2小时以前生成的文件

    copy from http://www.cnblogs.com/MasterMonkInTemple/p/7655734.html

    dim folder, file, mFSO, subfolder
      
    Set mFSO = CreateObject("Scripting.FileSystemObject")
    set folder=mFSO.GetFolder("C:UsersmsautotestuserAppDataLocalTemp")
    'Delete files
    dim df
    For Each file In folder.files
        'df=DateDiff("h",file.DateCreated,Now)    'Create Date
        df=DateDiff("h",file.DateLastModified,Now)   'Modify Date
        If (df>2) Then    '2 hours ago
            'MsgBox folder.path & "" & file.Name & vbTab & file.DateCreated
        'MsgBox folder.path & "" & file.Name & vbTab & file.DateLastModified
        On Error Resume Next
            file.Delete()
        End If
    Next
    'Delete folders
    set subfolder = Folder.subFolders
    For Each file In subfolder
        'df=DateDiff("h",file.DateCreated,Now)    'Create Date
        df=DateDiff("h",file.DateLastModified,Now)    'Modify Date
        If (df>2) Then    '2 hours ago
        On Error Resume Next
            mFSO.deleteFolder(folder.path & "" & file.Name)
        end if
    next
  • 相关阅读:
    c++错误崩溃3
    c++崩溃错误2
    c++多线程崩溃错误1
    MySQL UNSIGNED
    2PC和3PC
    proxy-target-class="false"与proxy-target-class="true"区别
    Spring MVC processing flow
    Spring中自动装配的模式
    Spring中BeanFactory和ApplicationContext的区别
    什么是Spring
  • 原文地址:https://www.cnblogs.com/kill0001000/p/7655898.html
Copyright © 2011-2022 走看看