Objeto ASP TextStream
O objeto TextStream é usado para acessar o conteúdo de um arquivo de texto.
Mais exemplos
de texto Como ler um arquivo de texto.
Como ler apenas uma parte de um arquivo TextStream.
Como ler uma linha de um arquivo TextStream.
Como ler todas as linhas de um arquivo TextStream.
Como pular um número especificado de caracteres ao ler o arquivo TextStream.
Como pular uma linha ao ler o arquivo TextStream.
Como retornar o número da linha atual em um arquivo TextStream.
Como obter o número da coluna do caractere atual em um arquivo.
O objeto TextStream
O objeto TextStream é usado para acessar o conteúdo de arquivos de texto.
O código a seguir cria um arquivo de texto (c:\test.txt) e grava algum texto no arquivo (a variável f é uma instância do 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 criar uma instância do objeto TextStream, você pode usar os métodos CreateTextFile ou OpenTextFile do objeto FileSystemObject ou pode usar o método OpenAsTextStream do objeto File.
As propriedades e métodos do objeto TextStream estão descritos abaixo:
Propriedades
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 |