0
我在HTML文件中有一個VBScript函數,如下所示,我嘗試在C:驅動器中打開一個日誌文件。使用VB腳本打開最近的日誌文件
日誌文件是每天生成的,我只想打開今天創建的日誌文件,只需單擊一個按鈕。文件名是具有日期戳是:24Jun2014.log
,25June2014.log
任何人都可以建議我怎麼能得到的只有基於日誌文件名稱上述日期戳最近的文件,然後打開它爲我下面的代碼?
VBScript來打開日誌文件
<script type="text/Vbscript">
Option Explicit
Dim File
File = "C:\24Jun2014.log"
'***********************************************************
Function LogOpen()
Dim Ws,iReturn,strError
Set ws = CreateObject("WScript.Shell")
On Error Resume Next
iReturn = Ws.Run(File,1,False)
If Err.Number <> 0 Then
strError = "<b><font color=Red>The file "& File &" dosen't exists !</font></b>"
myDiv.InnerHTML = strError
Exit Function
End If
End Function
'***********************************************************
</script>
HTML點擊並打開日誌文件:
<div class="tabpage" id="tabpage_1">
<h2>Application log</h2>
<center><input type="button" name="Log" id="Start" value="Application LogFile" onclick="LogOpen()">
</div>
日期造物主財產
Function ShowFileInfo(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
ShowFileInfo = "Created: " & f.DateCreated
End Function
我只有C:驅動器中的文件,正如您所建議的,我現在檢查了datecreated屬性文件並在原始文章中添加了代碼片段。但在我的情況下,我需要檢查文件的名稱,其中有日期戳本身。我不需要系統屬性。我的代碼可以處理文件名,並可以根據日期命名爲date.log,因此我需要閱讀2014年2月25日或2014年6月24日的文本,然後必須按照最近的文本顯示它。你能否在這方面給我任何建議。 – ScriptLearner