ASP TextStream Object

## 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 TextStream Object

« Previous
Next Chapter »

The TextStream object is used to access the contents of a text file.

## Try it Yourself - Examples

Read textfile
How to read from a text file.

Read only a part of a textfile
How to only read a part of a TextStream file.

Read one line of a textfile
How to read one line from a TextStream file.

Read all lines from a textfile
How to read all the lines from a TextStream file.

Skip a part of a textfile
How to skip a specified number of characters when reading the TextStream file.

Skip a line of a textfile
How to skip a line when reading the TextStream file.

Return line-number
How to return the current line number in a TextStream file.

Get column number
How to get the column number of the current character in a file.

## The TextStream Object

The TextStream object is used to access the contents of text files.

The following code creates a text file (c:\test.txt) and then writes some text to the file (the variable f is an instance of the TextStream object):

<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile("c:\test.txt",true)
f.WriteLine("Hello World!")
f.Close
set f=nothing
set fs=nothing
%>

To create an instance of the TextStream object you can use the CreateTextFile or OpenTextFile methods of the FileSystemObject object, or you can use the OpenAsTextStream method of the File object.

The TextStream object's properties and methods are described below:

### Properties

Property | Description
--- | ---
AtEndOfLine | Returns true if the file pointer is positioned immediately before the end-of-line marker in a TextStream file, and false if not
AtEndOfStream | Returns true if the file pointer is at the end of a TextStream file, and false if not
Column | Returns the column number of the current character position in an input stream
Line | Returns the current line number in a TextStream file

### Methods

Method | Description
--- | ---
Close | Closes an open TextStream file
Read | Reads a specified number of characters from a TextStream file and returns the result
ReadAll | Reads an entire TextStream file and returns the result
ReadLine | Reads one line from a TextStream file and returns the result
Skip | Skips a specified number of characters when reading a TextStream file
SkipLine | Skips the next line when reading a TextStream file
Write | Writes a specified text to a TextStream file
WriteLine | Writes a specified text and a new-line character to a TextStream file
WriteBlankLines | Writes a specified number of new-line character to a TextStream file

« Previous
Next Chapter »

## 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