|
思路:
1、转到指定的目录;
2、按修改时间来排序文件
下面是我以前写过的一个查找指定目录下面,以指定文件名大头的最新的文件的例子:
- Function getLatestFilebyCreateTime(folderspec, rule1)
- Dim fso, f, f1, f2, fc, s1,s2
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set f = fso.GetFolder(folderspec)
- Set fc = f.Files
- s1 = "NULL"
- s2 = Date
- For Each f1 in fc
- if StrComp(Left(CStr(f1.name),Len(rule1)), rule1) = 0 then
- If s2 < f1.DateLastModified Then
- s2 = f1.DateLastModified
- s1 = f1.name
- End If
-
- end if
- Next
- getLatestFilebyCreateTime = s1
- End Function
- Msgbox(getLatestFilebyCreateTime("c:\tt\", "AA_"))
复制代码 |
|