主题:  用ASP写入*.txt文本内容时的困难

灰飞湮灭√

职务:普通成员
等级:1
金币:0.0
发贴:1
#12002/12/25 2:45:36
<%
dim FS,FStream
dim Phypath
dim OpenTextFile,CreateTextFile
dim VisitNum

Phypath=Server.MapPath(".\")&"\count.txt"

Set FS=Server.CreateObject("Scripting.FileSystemObject")
Set FStream=FS.OpenTextFile(Phypath,1,false,-2)
VisitNum=FStream.ReadLine
FStream.close
'=====================================文件读取完毕,取得上次访问量VisitNum
Set FStream=FS.CreateTextFile(Phypath,true,false)
Application.Lock
Application("VisitNum")=VisitNum+1
FStream.WriteLine(VisitNum)
Application.UnLock
FStream.close
'=====================================计数器操作完毕,返回新的VisitNum
response.Write "
您是本站第"_
&"" & Application("VisitNum") & "位访客
"
%>

'=========================================

以上过程在测试中,始终提示“没有创建文本及写入数据的权限”
错误码如下:

Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft VBScript 运行时错误 错误 '800a0046'

没有权限

/cs/count.asp,行24

==============================================

本人在IIS中设置了该文件所在虚拟目录的权限有读取和写入的权限,
但该站点中的文件只能读取数据还是不能写入数据,请高手指点该怎么玩!



绿茶

职务:普通成员
等级:8
金币:10.0
发贴:19267
#22002/12/25 12:21:32
给你一个计数器比较一下吧
<%
cnt=0
dnt=0
s=Request.ServerVariables("path_translated")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
cName=Server.MapPath("chy.cnt")
dName=Server.MapPath("dchy.cnt")
Set objCountFile = objFSO.OpenTextFile(cName,1,True)
If Not objCountFile.AtEndOfStream Then cnt=CLng(objCountFile.ReadAll)
objCountFile.Close
Set objCountFile=Nothing
cnt=cnt+1
Set objCountFile=objFSO.CreateTextFile(cName,True)
objCountFile.Write cnt
objCountFile.Close
Set objCountFile=Nothing

if application("dntime")<=cint(hour(time())) then
    Set objCountFile = objFSO.OpenTextFile(dName,1,True)
    If Not objCountFile.AtEndOfStream Then dnt=CLng(objCountFile.ReadAll)
    objCountFile.Close
    Set objCountFile=Nothing
end if
application("dntime")=cint(hour(time()))
dnt=dnt+1
Set objCountFile=objFSO.CreateTextFile(dName,True)
objCountFile.Write dnt
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing

t=(cint(day(date()))*24+cint(hour(time())))*60+cint(minute(time()))
k=0
i=1
y=0
Do While application("zxip"&i)<>""
    if application("zxip"&i)=Request.ServerVariables("REMOTE_ADDR") then
        application("zxsj"&i)=t
        y=1
    end if
    if t-application("zxsj"&i)>9 or t        k=k+1
    else
        if k>0 then
            application.lock
            application("zxip"&i-k)=application("zxip"&i)
            application("zxsj"&i-k)=application("zxsj"&i)
            application.unlock
        end if
    end if
    if k>0 then
        application.lock
        application("zxip"&i)=""
        application.unlock
    end if
    i=i+1
loop
if y=0 then
    application("zxip"&i)=Request.ServerVariables("REMOTE_ADDR")
    application("zxsj"&i)=t
else
    i=i-1
end if%>



起访问次数:<%=cnt%>   今日访问次数:<%=dnt%>
  当前在线<%=i%>