龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp编程 >

asp入门教程:ASP Server 对象简单

时间:2012-12-31 22:56来源:未知 作者:admin 点击:
分享到:
asp入门教程:ASP Server 对象简单 在ASP服务器对象用于访问属性和方法在服务器上。 好了下面我们来看一个实例: html body % Set fs = Server.CreateObject(Scripting.FileSystemObject) Set rs = fs.GetFile(Server

asp入门教程:ASP Server 对象简单

在ASP服务器对象用于访问属性和方法在服务器上。

好了下面我们来看一个实例:

<html>
<body>

<%
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
%>

</body>
</html>

This file was last modified on: 01/10/2007 03:40:59

实例二.

<html>
<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"><img border="0" src="/images/btn_view_text.gif"></a>
</p>
输出结果.

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

%>
<html>
<body>
<p>
This page has been visited <%=fcount%>  times.
</p>
</body>
</html>
 输出结果.

This page has been visited 12345 times.

转载请注明来自http://www.111cn.cn/asp/asp.html


精彩图集

赞助商链接