Windows NT/2000/XP/2003/2008 PageActive Server Page > テキストファイルの書き込み/読み込み(ASP)
テキストファイルの書き込み/読み込み(ASP)





テキストファイルの書き込み

ASPを使用してテキストファイルの書き込みをします。

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FS = Server.CreateObject("Scripting.FileSystemObject")

Set TextFile = Fs.OpenTextFile("テキストファイル名", ForAppending, True)

TextFile.WriteLine "書き込むテキスト"
' オブジェクトを解放
Set TextFile = Nothing
Set FS = Nothing


テキストファイルの読み込み

ASPを使用してテキストファイルの書き込みをします。

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FS = Server.CreateObject("Scripting.FileSystemObject")

Set TextFile = Fs.OpenTextFile("テキストファイル名", ForReading, True)

read_text = TextFile.ReadLine
' オブジェクトを解放
Set TextFile = Nothing
Set FS = Nothing


OpenTextFileの第二パラメータ
1 - ForReading 読み込み専用ファイルとしてオープンします
2 - ForWriting 書き込み専用ファイルとしてオープンします
8 - ForAppending ファイルの最後に追記で書き込み専用ファイルとしてオープンします

OpenTextFileの第三パラメータ
True - 新しいファイルを作成します。
Flase - 新しいファイルを作成しません。


キャラ&ホビー格安通販 あみあみ