Name

Close (TextStream Object) — tsObj .Close

Synopsis

Closes a text file that has been opened as a TextStream object.

Parameters

None

Example

<%

' Dimension local variables. 
Dim fsoObject   ' FileSystemObject
Dim tsObject    ' TextStream Object

' Instantiate the FileSystemObject variable.
Set fsoObject = Server.CreateObject( _
                "Scripting.FileSystemObject")
' Using the OpenTextFile method of fsoObject, initialize 
' the File object.
Set tsObject = fsoObject.OpenTextFile( _
               "d:\docs\test.txt", ForReading, False)

' Read into the string the contents of the text file.
strContents = tsObject.ReadAll
' Close the open text file.
tsObject.Close
. . . [additional code]

%>

Notes

You can have only a limited number of open files in your application (similar to the use of open files in Visual Basic), so it is important to close all open text files after you are finished with them.

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.