%
Public Function ReportFileStatus(FileName)
Dim msg,fso
msg = -1
Set fso = Server.CreateObject(Scripting.FileSystemObject)
If (fso.FileExists(FileName)) Then
msg = 1
Else
msg = -1
End If
ReportFileStatus = msg
End Function
Public Function ReadTxtFile(FileName)
Const ForReading = 1, ForWriting = 2
Dim otf, msg, fso
set fso=CreateObject(Scripting.FileSystemObject)
If ReportFileStatus(FileName) = 1 then
Set otf = fso.OpenTextFile(FileName,ForReading)
if otf.atendofstream true then
msg = otf.readAll
ReadTxtFile = msg
otf.Close
Else
ReadTxtFile = -1
End if
End if
End Function
Public Function WriteTxtFile(FileName)
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
Dim fso, msg, ctf, otf
Set fso = Server.CreateObject(Scripting.FileSystemObject)
msg=ReadTxtFile(FileName)
set ctf=fso.CreateTextFile(FileName,true)
ctf.Close
set otf=fso.OpenTextFile(FileName,ForWriting, True)
otf.Write Cstr(Clng(msg)+1)
otf.Close
If ReportFileStatus(FileName) = 1 then
WriteTxtFile = 1
Else
WriteTxtFile = -1
End if
End Function
Function Spath(Rpath)
Spath=Server.MapPath(Rpath)
End Function
WriteTxtFile Spath(count.txt)
%
这是vbs,是用作网站访问人数统计的,它和js思路一样,只是语法不同,稍微改一下就可以用了,这对你来说是小KS啦。
取消
评论