| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
学习型 ASP/PHP/ASP.NET 主机 35元/年全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
赛孚耐:软件保护加密专家身份认证令牌USB KEY  
共有 333 人关注过本帖
标题:[求助]这里是一段读取记事本中的数,来统计访问数的代码。帮我看看哪里出错 ...
收藏  订阅  推荐  打印 
风中的承诺
Rank: 3Rank: 3
等级:中级会员
帖子:330
积分:3400
注册:2004-10-31
[求助]这里是一段读取记事本中的数,来统计访问数的代码。帮我看看哪里出错了,谢谢

<%
Application.Lock
Set fs=Server.CreateObject("Scripting.FileSystemObject")
counter_file=Server.MapPath("/counter.txt")
Set txt=fs.OpenTextFile(counter_file)
Application("counter")=txt.ReadLine
txt.Close
Application("counter")=Application("counter")+1
Set txt=fs.CreateTextFile(counter_file,true)
txt.WriteLine(Application("counter"))
txt.Close
Application.UnLock
%>
搜索更多相关主题的帖子: counter  txt  Application  记事本  Set  
2005-3-29 12:22
griefforyou
Rank: 12Rank: 12Rank: 12
等级:贵宾
威望:27
帖子:3338
积分:33882
注册:2004-4-15

<% on error resume next Application.Lock Set fs=Server.CreateObject("Scripting.FileSystemObject") counter_file=Server.MapPath("counter.txt") Set txt=fs.OpenTextFile(counter_file,1,true) '错误在于,如果开始没有这个counter.txt打开文件会出错,此时我们可以加上参数使其创建文件

Application("counter")=txt.ReadLine txt.Close if Application("counter")="" then Application("counter")=1 else Application("counter")=Application("counter")+1 end if Set txt=fs.CreateTextFile(counter_file,true) txt.WriteLine(Application("counter")) txt.Close Response.Write Application("counter") Application.UnLock

if err then response.write err.Description end if

%>

[此贴子已经被作者于2005-3-29 14:43:50编辑过]


四月天原创文学网 http://yc.4yt.net
2005-3-29 14:42
风中的承诺
Rank: 3Rank: 3
等级:中级会员
帖子:330
积分:3400
注册:2004-10-31

哦,多谢哈

I love you not because of who you are, but because of who I am when I am with you!
2005-3-31 12:36
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.109917 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved