ASP OpenTextFile Method

## ASP Tutorial

ASP HOME ASP Introduction ASP Install ASP Syntax ASP Variables ASP Procedures ASP Forms ASP Cookies ASP Session ASP Application ASP #include ASP Global.asa ASP Send e-mail

## ASP Objects

ASP Response ASP Request ASP Application ASP Session ASP Server ASP Error ASP FileSystem ASP TextStream ASP Drive ASP File ASP Folder ASP Dictionary ASP ADO

## ASP Components

ASP AdRotator ASP BrowserCap ASP Content Linking ASP Content Rotator

## ASP and AJAX

AJAX Intro AJAX ASP AJAX Database

## ASP Summary

ASP Quick Ref ASP Summary

## ASP Examples

ASP Examples ASP Quiz ASP Certificate

# ASP OpenTextFile Method

Complete FileSystemObject Object Reference

The OpenTextFile method opens a specified file and returns a TextStream object that can be used to access the file.

### Syntax

FileSystemObject.OpenTextFile(fname,mode,create,format)

Parameter | Description
--- | ---
fname | Required. The name of the file to open
mode | Optional. How to open the file 1=ForReading - Open a file for reading. You cannot write to this file. 2=ForWriting - Open a file for writing. 8=ForAppending - Open a file and write to the end of the file.
create | Optional. Sets whether a new file can be created if the filename does not exist. True indicates that a new file can be created, and False indicates that a new file will not be created. False is default
format | Optional. The format of the file 0=TristateFalse - Open the file as ASCII. This is default. -1=TristateTrue - Open the file as Unicode. -2=TristateUseDefault - Open the file using the system default.

### Example

<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
%>

Complete FileSystemObject Object Reference

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE