如何查出服務器中所有文件他們的最後一次存取日期
比如我想查出服務器中所有存儲日期在2004/1/1日以前的文件列表
不知要如何寫程序,請高手幫忙!

解决方案 »

  1.   

    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=198076
    下面的代码用一个文件举例说明了  DateCreated、DateLastAccessed  属性的用法:  
     
    Sub  ShowFileAccessInfo(filespec)  
           Dim  fs,  f,  s  
           Set  fs  =  CreateObject("Scripting.FileSystemObject")  
           Set  f  =  fs.GetFile(filespec)  
           s  =  UCase(filespec)  &  vbCrLf  
           s  =  s  &  "Created:  "  &  f.DateCreated  &  vbCrLf  
           s  =  s  &  "Last  Accessed:  "  &  f.DateLastAccessed  &  vbCrLf  
           s  =  s  &  "Last  Modified:  "  &  f.DateLastModified      
           MsgBox  s,  0,  "File  Access  Info"  
    End  Sub  
      

  2.   

    http://community.csdn.net/Expert/topic/3238/3238089.xml?temp=.176861
    有段代码:
    LGYAN(紫衣随想) 
    Sub DeleteJPGFile(ByVal folderspec As String)
    Dim fs, f, f1, fc
    Dim l As Date
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFolder(folderspec)
        Set fc = f.Files
        l = DateAdd("d", -14, Now) '计算两周前的日期 
        For Each f1 In fc
            If f1.DateLastModified < l Then Kill f1.Path
        Next
        Set fs = Nothing
        Set f = Nothing
        Set fc = Nothing
    End Sub