vbs向指定的文件添加內(nèi)容的函數(shù)
更新時間:2013年01月15日 23:26:14 作者:
用vbscript實現(xiàn)的向指定的文件寫字符串,第三個參數(shù)指定是否刪除原來的內(nèi)容,喜歡的朋友可以測試系
復制代碼 代碼如下:
'向指定的文件寫字符串,第三個參數(shù)指定是否刪除原來的內(nèi)容
Function Z_WriteFile(sFileName, sText, bAppend)
Dim fs, fso, iomode
if bAppend = True Then
iomode = 8 'ForAppending
else
iomode = 2 'ForWriting
end if
set fs = CreateObject("Scripting.FileSystemObject")
set fso = fs.OpenTextFile(sFileName, iomode, True) '第三個參數(shù)表明文件不存在,則新建文件
fso.WriteLine sText
fso.Close
set fso = Nothing
set fs = Nothing
End Function
Dim path, sFileName, sText
path = "E:\Program\VBScript"
sFileName = path & "\1.txt"
sText = "what can I do for you"
Z_WriteFile sFileName, sText, True
Z_WriteFile中的第三個參數(shù)指定向文件末尾添加內(nèi)容還是清除原來的內(nèi)容再插入內(nèi)容。
相關(guān)文章
VBS InternetExplorer.Application的屬性和方法介紹
V這篇文章主要是介紹vBS InternetExplorer.Application 屬性和方法,需要的朋友可以參考一下2009-07-07