Objeto ASP TextStream
El objeto TextStream se utiliza para acceder al contenido de un archivo de texto.
Más ejemplos
archivo de texto Cómo leer desde un archivo de texto.
archivo de texto Cómo leer solo una parte de un archivo TextStream.
archivo de texto Cómo leer una línea de un archivo TextStream.
las líneas de un archivo de texto Cómo leer todas las líneas de un archivo TextStream.
de texto Cómo omitir un número específico de caracteres al leer el archivo TextStream.
texto Cómo saltar una línea al leer el archivo TextStream.
Cómo devolver el número de línea actual en un archivo TextStream.
Cómo obtener el número de columna del carácter actual en un archivo.
El objeto TextStream
El objeto TextStream se utiliza para acceder al contenido de los archivos de texto.
El siguiente código crea un archivo de texto (c:\test.txt) y luego escribe algo de texto en el archivo (la variable f es una instancia del objeto TextStream):
<%
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
%>
Para crear una instancia del objeto TextStream, puede usar los métodos CreateTextFile u OpenTextFile del objeto FileSystemObject, o puede usar el método OpenAsTextStream del objeto File.
Las propiedades y métodos del objeto TextStream se describen a continuación:
Propiedades
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 |
Métodos
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 |