%> 我知道要用到<% var path = Server.MapPath("test.txt"); var MyFileObject = Server.CreateObject("Scripting.FileSystemObject"); var MyTextFile = MyFileObject.CreateTextFile(path); MyTextFile.WriteLine(""); MyTextFile.Close(); %>这些命令,可具体怎么写呢?
复制代码 代码如下:
给你一个最全的吧: <script language = "vbscript" runat = "server"> sub application_onstart '取的计数文件的真实路径 countfile=server.mappath("count.txt") '创建文件系统对象实例 set myfso = server.createobject("scripting.filesystemobject") '若计数文件不存在 if not myfso.fileexists(countfile) then '创建该文件及取得textstream对象实例 set mytextstream = myfso.createtextfile(countfile, True) application.lock application("online") = 0 application("counter") = 0 application.unlock '将计数值写入文件 mytextstream.writeline(cstr(application("counter"))) else '以只读的方式打开 set mytextstream = myfso.opentextfile(countfile,1,false) '读一行,并将值赋给计数变量 application("counter") = mytextstream.readline end if