【www.bbyears.com--ASP入门】
asp入门教程:ASP Server 对象简单
在ASP服务器对象用于访问属性和方法在服务器上。
好了下面我们来看一个实例:
<%
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set rs = fs.GetFile(Server.MapPath("demo_lastmodified.asp"))
modified = rs.DateLastModified
%>
This file was last modified on: <%response.write(modified)
Set rs = Nothing
Set fs = Nothing
%>
This file was last modified on: 01/10/2007 03:40:59
实例二.
<%
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("
")
Wend
%>
输出结果.
Hello World line 1
Hello World line 2
Hello World line 3
实例三.
<%
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 is 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
%>
This page has been visited <%=fcount%> times.
输出结果.
This page has been visited 12345 times.
转载请注明来自http://www.111cn.net/asp/asp.html