You are on page 1of 3

File System Object Methods

1. CREATEFOLDER :
Creates a folder.
object.CreateFolder(foldername)

Arguments
object
Required. Always the name of a FileSystemObject.
foldername
Required. String expression that identifies the folder to create.
Ex : Set FSO = CreateObject(Scripting.FileSystemObject)
Set VarName = FSO.CreateFolder(Path of File)
Note: An error occurs if the specified folder already exists.
************************************************************************
2. CREATETEXTFILE:
Creates a specified file name and returns a TextStream object that can be used to
read from or write to the file.
object.CreateTextFile(filename)

Ex:

Set FSO = CreateObject (Scripting.FileSystemObject)


Set VarName = FSO.CreateTextFile (Path of File with Extension)

************************************************************************
3. OPENTEXTFILE :
Opens a specified file and returns a TextStream object that can be used to read from,
write to, or append to the file.
object.OpenTextFile(filename)

.
Ex : Set FSO = CreateObject (Scripting.FileSystemObject)

Set VarName = FSO.OpenTextFile (Path of File with Extension)


Settings : The iomode argument can have any of the following settings:
Constant
For Reading
For Writing
For Appending

Value
Description
1
Open a file for reading only. You can't write to this file.
2
Open a file for writing.
8
Open a file and write to the end of the file.

***********************************************************************
4. READ :
Reads a specified number of characters from a TextStream file and returns the
resulting string.
object.Read(characters)

Ex : Set FSO = CreateObject (Scripting.FileSystemObject)


Set VarName = FSO.OpenTextFile (Path of File with Extension)
VarName.Read.
***********************************************************************
5. READLINE :
Reads an entire line (up to, but not including, the newline character) from a
TextStream file and returns the resulting string.
object.ReadLine( )

***********************************************************************
6. WRITE :
Writes a specified string to a TextStream file.
object.Write(string)

Remarks

Specified strings are written to the file with no intervening spaces or characters
between each string. Use the WriteLine method to write a newline character or
a string that ends with a newline character.

***********************************************************************
7. WRITELINE :
Writes a specified string and newline character to a TextStream file.
object.WriteLine ([string])

Arguments
object
Required. Always the name of a TextStream object.
string
Optional. The text you want to write to the file. If omitted, a newline character
is written to the file
************************************************************************

You might also like