Table of contents
TOC
折叠目录
展开目录

FileSystemObject 对象FileSystemObject Object

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

说明提供对计算机的文件系统的访问。语法实例说明下面的代码阐释了如何FileSystemObject是用来返回一个TextStream对象,它可以读取或写入:Description Provides access to a computer's file system. SyntaxScripting.FileSystemObjectRemarks The following code illustrates how the FileSystemObject is used to return a TextStream object that can be read from or written to:

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\testfile.txt", True)
a.WriteLine("This is a test.")
a.Close

在上述代码中,无论函数返回FileSystemObject ( fs )。CreateTextFile方法创建TextStream对象的文件 ( a ),并WriteLine方法将一行文本写入到创建的文本文件。Close方法刷新缓冲区并关闭该文件。In the code shown above, the CreateObject function returns the FileSystemObject ( fs ). The CreateTextFile method then creates the file as a TextStream object ( a ), and the WriteLine method writes a line of text to the created text file. The Close method flushes the buffer and closes the file.

© 2018 Microsoft