我無法在VBScript中獲得以下功能。我正在嘗試獲取文件夾中的所有文件,並通過它們循環獲取編號最高的文件。 (文件名格式是log_XXX.txt)我遇到的問題是代碼永遠不會進入我的For Each
循環。我是VBScript的新手,但我似乎不明白爲什麼這不起作用。每個VBScript都不起作用
Function GetFileNumber(folderspec)
Dim fso, f, f1, fc, s, tempHighNum
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
WScript.Echo f.Files.Count : rem prints 3
Set fc = f.Files
WScript.Echo fc.Count : rem prints 3
Set tempHighNum = "000"
For Each f1 in fc
WScript.Echo f1.Size : rem does not print
WScript.Echo f1.Type : rem does not print
WScript.Echo f1.Name : rem does not print
s = Right(f1.name,3)
IF NOT(ISNULL(s)) THEN
IF (s > tempHighNum) THEN
tempHighNum = s
END IF
END IF
Next
GetFileNumber = tempHighNum
End Function
打我吧..我確認。 – madcolor 2009-04-30 19:28:26