CreateTextFile 的小问题

afei2003 2004-09-06 09:48:40

<%
CountFile=server.MapPath("txtcounter.txt")
set FileObject=server.CreateObject("Scripting.FileSystemObject")
我写了一个与页面分离的计数器的小asp脚本。可出现一个小问题,望指点一二:
代码如下:
count.asp
-----------------------------------
set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)
counnter=Out.ReadLine
Out.Close

set FileObject=Server.CreateObject("Scripting.FileSystemObject")
set Out=FileObject.CreateTextFile(CountFile,1,TRUE,FALSE)
Application.Lock
counter= counter+1
Out.WriteLine(counter)
Application.UnLock
Response.Write"document.write("&counter&")"
Out.Close

%>
-----------------------------------------------------------------
用interdev调试跳出如下错误信息:
an exception of type 'Microsoft VBScript 运行时错误:错误的参数个数或无效的参数属性值:
'FileObject.CreateTextFile'was not handled.


...全文
89 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
afei2003 2004-09-06
  • 打赏
  • 举报
回复
谢谢
CreateTextFile(CountFile,TRUE,FALSE)

mind_1220 2004-09-06
  • 打赏
  • 举报
回复
这个是别人写的 你看看:
<%
'----------------------------------------------------------计数程序开始
dim fileobject,countfile,out,counter,picno,pp
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
CountFile=Server.MapPath("count.txt")
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
'----------------------------------------------------------计数程序结束

if counter>99 then counter=0 '不能超过某个值,这个地
方你注意了,不能跟显示的数字变量一样:(
if counter<10 then '我现在只有10张图片,10以下是
'多 少就显示多少
picno=counter
else
picno=(counter mod 10) '大于10只取个位,因为我一共只有10
张 图片:(
end if
Out.WriteLine(counter) '把当前的计数值存在counter.txt里面
Application.unlock
Out.Close
%>

smallyear 2004-09-06
  • 打赏
  • 举报
回复
CreateTextFile(CountFile,TRUE,FALSE)
mind_1220 2004-09-06
  • 打赏
  • 举报
回复
set Out=FileObject.CreateTextFile(CountFile,1,TRUE,FALSE)
有问题
iuhxq 2004-09-06
  • 打赏
  • 举报
回复
估计是FileObject.CreateTextFile参数有问题,可以查看一下VBSCRIPT手册,里面详细讲解了FSO的使用方法

asp2004.net有下载

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧