vbs向指定的文件添加內(nèi)容的函數(shù)
來源:易賢網(wǎng) 閱讀:1674 次 日期:2016-06-30 11:17:29
溫馨提示:易賢網(wǎng)小編為您整理了“vbs向指定的文件添加內(nèi)容的函數(shù)”,方便廣大網(wǎng)友查閱!

用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)容。

更多信息請查看腳本欄目
易賢網(wǎng)手機(jī)網(wǎng)站地址:vbs向指定的文件添加內(nèi)容的函數(shù)
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點

版權(quán)所有:易賢網(wǎng)