vbs中怎么向指定文件添加內(nèi)容,相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。
復(fù)制代碼 代碼如下:
'向指定的文件寫字符串,第三個(gè)參數(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) '第三個(gè)參數(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
看完上述內(nèi)容,你們掌握vbs中怎么向指定文件添加內(nèi)容的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!