global.asa

来自「项目开发对初学者来说非常重要」· ASA 代码 · 共 28 行

ASA
28
字号
<script language="VBScript" runat="Server">
Sub Application_OnStart
    Set fs = Server.CreateObject("Scripting.FileSystemObject")
    counter_file = Server.MapPath("/counter.txt")
    Set txt = fs.OpenTextFile( counter_file )
    Application("counter") = txt.ReadLine
    txt.Close

    ' 将FileSystemObject对象及counter.txt的实际路径
    ' 保存Application对象中
    Set Application("fs") = fs 
    Application("counter_file") = counter_file

End Sub

Sub Application_OnEnd
    ' 将保存在 Application 对象中 FileSystemObject 对象
    ' 及counter.txt 的实际路径读出来
    Set fs = Application("fs")
    counter_file = Application("counter_file")

    Set txt = fs.CreateTextFile( counter_file, True )
    txt.WriteLine(Application("counter"))
    txt.Close
End Sub

</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?