ASPTextStreamオブジェクト_
TextStreamオブジェクトは、テキストファイルの内容にアクセスするために使用されます。
その他の例
テキストファイルを読むテキストファイルから読む方法
ファイルの一部のみを読み取る方法。
ファイルから1行を読み取る方法。
ファイルからすべての行を読み取る方法。
スキップするTextStreamファイルを読み取るときに指定された文字数をスキップする方法。
TextStreamファイルを読み取るときに1行をスキップする方法。
を返す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 |