ASP Getting Started Tutorial: ASP Server Object Simple
The ASP server object is used to access properties and methods on the server.
Okay, let's take a look at an example here:
<body>
<%
Set fs = Server.CreateObject ("Scripting.FileSystemObject")
Set rs = fs. GetFile (Server.MapPath ("demo_lastmodified.asp"))
Modified = Rs. DateLastModified
%>
This file is last modified on: <%response.write (modified)
Set rs = Nothing
Set fs = Nothing
%>
</body>
This file is last modified on:01/10/2007 03:40:59
Instance two.
<body>
<%
Set FS = Server.CreateObject ("Scripting.FileSystemObject")
Set RS = FS. OpenTextFile (Server.MapPath ("text") & "TextFile.txt", 1)
While not Rs. AtEndOfStream
Response.Write RS. ReadLine
Response.Write ("<br/>")
Wend
%>
<p>
<a href= "Text/textfile.txt" ></a>
</p>
Output results.
Hello World Line 1
Hello World Line 2
Hello World Line 3
Instance three.
<%
Set fs=server.createobject ("Scripting.FileSystemObject")
Set Rs=fs. OpenTextFile (Server.MapPath ("Counter.txt"), 1, False)
Fcount=rs. ReadLine
Rs. Close
Fcount=fcount+1
' This code was disabled due to the Write access security on our server:
' Set rs=fs. OpenTextFile (Server.MapPath ("Counter.txt"), 2, False)
' RS. Write Fcount
' RS. Close
Set rs=nothing
Set fs=nothing
%>
<body>
<p>
This page has been the visited <%=fcount%> times.
</p>
</body>
Output results.
This page has been the visited 12345 times.
Reprint please indicate from http://www.111cn.net/asp/asp.html