<%@ LANGUAGE="VBScript" %>
<% 'Set file i/o constants.
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
filename = ""
path = ("data") & "\" & filename
' Map filename to the physical path of the server.
operation = ("operation") %>
' Get requested action.
<html>
<head>
<title>Thousand Flowers Flying Processing Documents</title>
</head>
<body>
<font face="Arial,Helvetica" size=2>
<table bgcolor="#000000" border=0 cellpadding=1 cellspacing=0><tr><td>
<table bgcolor="#008080" border=0 cellpadding=8 cellspacing=0><tr valign=bottom><td>
<font face="Arial,Helvetica" size=2>
<form action="<% = ("script_NAME") %>" method="post">
<input name="operation" type="radio" value="create"> create
<input name="operation" type="radio" value="delete"> delete
<input name="operation" type="radio" value="read" checked> Read
<input name="operation" type="radio" value="write"> Write
<input name="operation" type="radio" value="append"> Add to
<p>
<center>
<input type="submit" value="Sure"> <input type="reset" value="Reset">
</center>
</form>
<p>
<a href=""><b>return</b></a>
</font>
</td></tr></table>
</td></tr></table>
<p>
<%
if operation = "create" then
call CreateFile(path)
call ReadFile(path)
elseif operation = "delete" then
call DeleteFile(path)
elseif operation = "read" then
call ReadFile(path)
elseif operation = "write" then
call WriteFile(path)
call ReadFile(path)
elseif operation = "append" then
call AppendFile(path)
call ReadFile(path)
end if
' Perform a request operation.
%>
<p>
</font>
</body></html>
<% sub CreateFile(path)
dim fs, file
set fs = CreateObject("")
if (path) then
(<b>oh,document" & filename & " Already exists,Creation failed!</b><br>" & vbCrLf)
' If the file already exists, an error message will be displayed
else
(Congratulations, " & filename & "Created successfully!<br>" & vbCrLf)
' Otherwise create it and write data
set file = (path)
(Towards" & filename & "Write data...<br>" & vbCrLf)
("Line 1 added " & Now() & ".")
("Line 2 added " & Now() & ".")
("Line 3 added " & Now() & ".")
("Line 4 added " & Now() & ".")
("Line 5 added " & Now() & ".")
()
end if
end sub
sub DeleteFile(path)
dim fs, file
set fs = CreateObject("")
if not (path) then
' If the file does not exist, an error message will be displayed.
(<b>oh,document" & filename & "Does not exist,What did you delete!</b><br>" & vbCrLf)
else
(Congratulations," & filename & "Delete successfully!<br>" & vbCrLf)
' Otherwise delete it.
(path)
end if
end sub
sub ReadFile(path)
dim fs, file
set fs = CreateObject("")
if not (path) then
(<b>oh,document" & filename & "Does not exist,What do you read!</b><br>" & vbCrLf)
' If the file does not exist, an error message will be displayed.
else
set file = (path, ForReading)
(Congratulations," & filename & "Read successfully!" & vbCrLf)
' Otherwise, open it and display the content.
("<p>" & vbCrLf)
("<hr size=1>" & vbCrLf)
("<font size=3><pre>" & vbCrLf)
do while not
( & vbCrLf)
loop
("</pre></font>" & vbCrLf)
("<hr size=1>" & vbCrLf)
()
end if
end sub
sub WriteFile(path)
dim fs, file
set fs = CreateObject("")
if not (path) then
(<b>oh,document" & filename & "Does not exist,What did you write!</b><br>" & vbCrLf)
' If the file does not exist, an error message will be displayed.
else
set file = (path, ForWriting)
' otherwise,Rewrite content.
(Rewriting file " & filename & ".<br>" & vbCrLf)
("Rewritting file with line 1 added " & Now() & ".")
("Rewritting file with line 2 added " & Now() & ".")
("Rewritting file with line 3 added " & Now() & ".")
()
end if
end sub
sub AppendFile(path)
dim fs, file
set fs = CreateObject("")
if (path) then
set file = (path)
if > 500 then
' If the file exists,Check its size and exit,If it exceeds500K.
(<b>oh,document" & filename & "Exceeded size limit, Adding failed!</b><br>" &
vbCrLf)
exit sub
end if
else
(oh,document" & filename & "Does not exist!But it will be created...<br>" & vbCrLf)
end if
' If the file does not exist,Show a prompt message.
(Add content to file" & filename & "...<br>" & vbCrLf)
set file = (path, ForAppending, true)
("New content added:" & Now() & ".")
' Open or create a file when you need to add new content to it
()
end sub %>
[1]