'比較源文件和替換后的文件 if dFileContents <> FileContents Then '保存替換后的文件 WriteFile FileName, dFileContents
Wscript.Echo "Replace done." If Len(ReplaceWith) <> Len(Find) Then '計算替換總數 Wscript.Echo _ ( (Len(dFileContents) - Len(FileContents)) / (Len(ReplaceWith)-Len(Find)) ) & _ " replacements." End If Else Wscript.Echo "Searched string Not In the source file" End If
'讀取文件 function GetFile(FileName) If FileName<>"" Then Dim FS, FileStream Set FS = CreateObject("Scripting.FileSystemObject") on error resume Next Set FileStream = FS.OpenTextFile(FileName) GetFile = FileStream.ReadAll End If End Function
'寫文件 function WriteFile(FileName, Contents) Dim OutStream, FS
on error resume Next Set FS = CreateObject("Scripting.FileSystemObject") Set OutStream = FS.OpenTextFile(FileName, 2, True) OutStream.Write Contents End Function
您可能感興趣的文章:
ASP、vbscript編碼模板ASP中一個用VBScript寫的隨機數類asp,VBscript語法錯誤,史上最全最詳細最精確vbscript腳本編程教程2利用fso來進行文件操作使用vbscript腳本在表單中進行選擇的代碼用vbscript腳本實現返回 IP 配置數據的代碼ASP里面令人震撼地Debug類(VBScript)調試JavaScript/VBScript腳本程序(IE篇)JavaScript/VBScript腳本程序調試(Wscript篇)枚舉域內計算機個數vbscript腳本(沒環境,沒測試)ASP/VBScript中CHR(0)的由來以及帶來的安全問題分析ASP(VBScript)中整除和取余ASP基礎知識VBScript基本元素講解ASP基礎入門第四篇(腳本變量、函數、過程和條件語句)