主题:关于ASP计数问题--用外部文本文件非数据库
fanlihang
[专家分:0] 发布于 2008-01-29 17:01:00
看书上写的只有方法没有代码(光盘无,电子书)在网上找了找,看不明白.这个要用到什么方法呢?
回复列表 (共5个回复)
沙发
a97191 [专家分:4040] 发布于 2008-01-29 17:57:00
用
set myfileobject=server.CreateObject("Scripting.FileSystemObject")
板凳
fanlihang [专家分:0] 发布于 2008-01-29 18:13:00
谢谢了.我试试
3 楼
fanlihang [专家分:0] 发布于 2008-01-29 18:14:00
能不能给这对象一两个简单的方法给我...写和读都不知道怎么写我.....
4 楼
a97191 [专家分:4040] 发布于 2008-01-29 18:24:00
set myfileobject=server.CreateObject("Scripting.FileSystemObject")
set mytextfile=myfileobject.OpenTextFile(server.MapPath("test.txt"),2,true)
mytextfile.WriteLine("这是一个测试") '写入
mytextfile.ReadLine '读出
5 楼
martine [专家分:4950] 发布于 2008-01-31 14:14:00
<%
dim images(20),img
CountFile=Server.MapPath("counter/counter.txt") ///文本文件
SET FileObject=Server.CreateObject("Scripting.FileSystemObject")
SET Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)
counter=Out.ReadLine
Out.Close
SET FileObject=Server.CreateObject("Scripting.FileSystemObject")
SET Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE)
Application.lock
counter=counter+1
Out.WriteLine(counter)
Application.unlock
Out.Close
countlen=len(counter)
response.write " 页面访问统计: "
for ic=1 to countlen
image=mid(counter,ic,1)
response.write "<img src='img/"&image&".gif'>"
next
response.write"</img> 次"
%>
要求放文本文件的文件夹counter有读写权限,其中的img是0-9个数字的10个图片.
我来回复