Text Stream Example
Use the form below to create a new HTML file, when you submit the form the file will be created and displayed at the bottom of the file list as New file
File: test-00.htm Created on: 29/08/2008 09:19:55
File: test-01.htm Created on: 29/08/2008 09:19:57
File: test-02.htm Created on: 12/11/2008 18:44:23
File: test-03.htm Created on: 07/02/2009 15:16:25
File: test-04.htm Created on: 20/02/2009 07:13:19
File: test-05.htm Created on: 03/11/2009 15:14:11
File: test-06.htm Created on: 22/12/2009 18:04:31
File: test-07.htm Created on: 04/02/2010 03:37:22
Code:
<%
Set file=Server.CreateObject("Scripting.FileSystemObject")
n = 0
do until lp = "Exit"
if n < 10 then
num = "0" & n
else
num = n
end if
If (file.FileExists("Drive:\Path\textstream\test" & num & ".htm"))=true Then
Response.Write("File test" & num & ".htm exists. <a href='textstream/test" & num & ".htm'>test" & num & ".htm</a><br>")
n = n + 1
Else
dim fs, f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile("Drive:\Path\textstream\test" & num & ".htm",true)
f.WriteLine("<html>")
f.WriteBlankLines(1)
f.WriteLine("<head>")
f.WriteLine("<meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>")
f.WriteLine("<title>New Page Generated by ASP</title>")
f.WriteLine("</head>")
f.WriteBlankLines(2)
f.WriteLine("<body>")
f.WriteLine("HELLO WORLD!")
f.WriteLine("<p> </p>")
f.WriteLine("File created @ " & time & "on " & Date)
f.WriteLine("<p> </p>")
f.WriteLine("HELLO WORLD!")
f.WriteLine("</body>")
f.WriteLine("</html>")
f.Close
set f=nothing
set fs=nothing
lp= "Exit"
End If
loop
set file=nothing
%>
<p> </p>
New file <a href="textstream/test<%=num%>.htm">test<%=num%>.htm</a><br>
You will need to change two lines at the top where it has Drive:\Path to your drive and path and you will need to have write permission on the final folder for the IUSER_ServerName user on the web server.
The page differs slightly to the code above in that the code will create a new file each time the page is loaded, where this page waits till the form is submitted before creating the file but both work in the same fassion.