Объект ASP TextStream
Объект TextStream используется для доступа к содержимому текстового файла.
Дополнительные примеры
Как читать из текстового файла.
Как читать только часть файла TextStream.
Как прочитать одну строку из файла TextStream.
Как прочитать все строки из файла TextStream.
Как пропустить указанное количество символов при чтении файла TextStream.
Как пропустить строку при чтении файла TextStream.
Как вернуть номер текущей строки в файле TextStream.
Как получить номер столбца текущего символа в файле.
Объект TextStream
Объект TextStream используется для доступа к содержимому текстовых файлов.
Следующий код создает текстовый файл (c:\test.txt), а затем записывает в него некоторый текст (переменная f является экземпляром объекта 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
%>
Чтобы создать экземпляр объекта TextStream, вы можете использовать методы CreateTextFile или OpenTextFile объекта FileSystemObject или вы можете использовать метод OpenAsTextStream объекта File.
Свойства и методы объекта TextStream описаны ниже:
Характеристики
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 |
Методы
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 |