web 2.0

ASP OpenAsTextStream() - File Object

ASP OpenAsTextStream() - File Object This the tutorial/example asp script how to write text file.

ShotDev Focus:
- ASP & Write text file.

Example

asp_file_write.asp


<% Option Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 3

Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Dim objFSO,objFile,objFileStm,objFileRead,strText
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(Server.MapPath("MyFiles/shotdev.txt"))

'*** Write ***'
Set objFileStm = objFile.OpenAsTextStream(ForWriting, TristateUseDefault)
objFileStm.Write("Hello ShotDev.Com!")
objFileStm.Close()

'*** Read ***'
Set objFileRead = objFile.OpenAsTextStream(ForReading, TristateUseDefault)
strText = objFileRead.ReadLine

Response.write strText

Set objFSO = Nothing

%>
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run

http://localhost/myasp/asp_file_write.asp.

Screenshot

ASP & Write text file.

.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.