ASP 텍스트 스트림 개체


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 개체의 인스턴스를 만들려면 FileSystemObject 개체의 CreateTextFile 또는 OpenTextFile 메서드를 사용하거나 File 개체의 OpenAsTextStream 메서드를 사용할 수 있습니다.

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