fso.OpenTextFile(filename, [IOMode], [Create], [Format]);
FSO OpenTextFile method accepts 4 types of parameters as shown in the above syntax.
1. Filename: this parameter accepts the filename along with its complete path where you want to create a text file or open the specified text file.
2. IOMode: Optional input output mode. This parameter allows you to open the file for reading, writing or appending. IOMode parameter supports following set of values:
1 = ForReading : for reading the text file
2 = ForWriting : for writing into the text file. This value opens the file and writes from the beginning i.e. first line.
8 = ForAppending : also for writing into the text file. This value opens the file but writes at the end of the file.
3. Create: Optional. Accepts the Boolean value i.e. true or false that indicates whether to create a new file if the specified file does not exist. If true then it creates a new file otherwise not. Default is true.
4. Format: Optional. Format of file as Unicode or ASCII. This parameter supports following values:
0 = TristateFalse: Open the file as ASCII (Default value)
-1 = TristateTrue: Open the file as Unicode
-2 = TristateMixed: Mixed mode
-2 = TristateUseDefault: Open the file as System Default type.
Example of FSO OpenTextFile Method