File System 物件

FileSystemObject 物件是用來存取伺服器上的檔案系統。

這個物件可以操控檔案。您也可以使用此物件擷取檔案系統資訊。

下列程式碼會建立文字檔 (c:\test.txt),然後將部分文字寫入檔案:

Dim fso, tso
Set fso = CreateObject("Scripting.FileSystemObject")
Set tso = fso.CreateTextFile("C:\test.txt", True)   ' Creates a text file (overwrites if exists).
tso.WriteLine("Hello, this is a test file.")        ' Writes text to the file.
tso.Close                                          ' Closes the file.

Set tso = Nothing
Set fso = Nothing