VBS教程 方法 OpenTextFile 方法

2022-09-24 13:36:15 字數 1166 閱讀 6894

開啟指定的檔案並返回乙個textstreamjvdihmzgfa物件,可以讀取、寫入此物件或將其追加到檔案。

object.opentextfile(filename[, iomode[, create[, format]]])

引數object

必選項。應為 filesystemobject 物件的名稱。

filename

必選項。字串表示式,指明要開啟的檔名稱。

iomode

可選項。輸入/輸出模式,是下列三個常數之一:forreading,forwriting,或 forappending。

create

可選項。boolean 值,指出當指定的filename不存在時是否能夠建立新檔案。允許建立新檔案時為true,否則為false。預設值為false

format

可選項。三個 tristate 值之一,指出以何種格式開啟檔案。若忽略此引數,則檔案以 ascii 格式開啟。

設定iomode引數可為下列設定之一:

常數值描述forreading1以唯讀模式開啟檔案。不能對此檔案進行寫操作。forwriting2以只寫方式開啟檔案。不能對此檔案進行讀操作。forappending8開啟檔案並在檔案末尾進行寫操作。

〈p〉format引數可為下列設定之一:

常數值描述tristateusedefault-2以系統預設格式開啟檔案。tristatetrue-1以 unicodjvdihmzgfae 格式開啟檔案程式設計客棧。tristatefalse 0以 ascii 格式開啟檔案。

說明以下**舉例說明如何使用opentextfile方法開啟寫檔案:

sub opentextfiletest const forreading = 1, forwriting = 2, forappendingwww.cppcns.com = 8 dim fso, f set fso = createobject("scripting.filesystemobject") set f =fso.opentextfile("c:\testfile.txt",for writing,tru程式設計客棧e)f.write "嗨,你好!"f.close

本文位址:

VBS教程 方法 FileExists 方法

如果指定的檔案存在返回true 否則返回false。object.fileexists filespec 引數object 必選項。應為 filesystemobject 物件的名稱。filespec 必選項。檔名,表示要確定是否存在的檔案。如果檔案不在當前資料夾中,則必須提供完整路徑名 絕對路徑或...

VBS教程 方法 GetFolder 方法

返回與指定的路徑中某資料夾相應的folder物件。objecwww.cppcns.comt.getfolder folderspec 引數object 必程式設計客棧選項。應為 filesystemobject 的名稱。folderspec 必選項。folderspec是指定資料夾的路徑 絕對路徑或...

VBS教程 方法 CopyFile 方法

將乙個或多個檔案從某位置複製到另一位置。object.copyfilesource,destination overwrite 引數object 必選項。應為 filesystemobject 物件的名稱。source 必選項。表示指定檔案的字串。要復程式設計客棧制乙個或多個檔案時,檔名中可以有萬用...