2015-06-30 70 views

回答

5

追加文本文件的內容,以您的頂線,用字符串覆蓋文本文件:

Option Explicit 

Const csFSpec = "31144630.txt" 
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject") 
Dim sAll : sAll  = "top line " & Now & vbCrLf 
If goFS.FileExists(csFSpec) Then sAll = sAll & goFS.OpenTextFile(csFSpec).ReadAll() 
goFS.CreateTextFile(csFSpec).Write sAll 

輸出:

cscript 31144630.vbs 

type 31144630.txt 
top line 6/30/2015 7:57:07 PM 

cscript 31144630.vbs 

type 31144630.txt 
top line 6/30/2015 7:57:25 PM 
top line 6/30/2015 7:57:07 PM 
相關問題