Oggetto TextStream ASP
L'oggetto TextStream viene utilizzato per accedere al contenuto di un file di testo.
Altri esempi
Come leggere da un file di testo.
Come leggere solo una parte di un file TextStream.
Come leggere una riga da un file TextStream.
Come leggere tutte le righe da un file TextStream.
Come saltare un numero specificato di caratteri durante la lettura del file TextStream.
Come saltare una riga durante la lettura del file TextStream.
Come restituire il numero di riga corrente in un file TextStream.
di colonna Come ottenere il numero di colonna del carattere corrente in un file.
L'oggetto TextStream
L'oggetto TextStream viene utilizzato per accedere al contenuto dei file di testo.
Il codice seguente crea un file di testo (c:\test.txt) e quindi scrive del testo nel file (la variabile f è un'istanza dell'oggetto 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
%>
Per creare un'istanza dell'oggetto TextStream è possibile utilizzare i metodi CreateTextFile o OpenTextFile dell'oggetto FileSystemObject oppure è possibile utilizzare il metodo OpenAsTextStream dell'oggetto File.
Le proprietà e i metodi dell'oggetto TextStream sono descritti di seguito:
Proprietà
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 |
Metodi
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 |