|
我補充一下吧:
如下代碼加入:
'獲取指定目錄下,最后存取日期之檔案名
Function LastModiFile(folderspec) As String
Dim fs, f, f1, fc
Dim time1 As Date
Dim Name1 As String
time1 = Now()
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
If f1.datelastmodified < time1 Then
time1 = f1.datelastaccessed 'datelastmodified 最后修改日期
Name1 = f1.Name
End If
Next
LastModiFile = Name1
End Function
'調用函數,
Private Sub Command3_Click()
MsgBox LastModiFile(CurrentProject.Path)
End Sub
|
|