使用filesysobj对象
在 session_onstart session_onend 中,可能会出问题的,因为每一个访问者都可能操作到,
如果想建立可以在application_onstart Application_OnEnd中,
可参考以下:
Function CreateFolderDemo
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateFolder("c:\New Folder")
CreateFolderDemo = f.Path
End Function
Sub DeleteAFolder(filespec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder(filespec)
End Sub
<SCRIPT Language="VBScript" RunAt="Server">
Sub Session_OnStart()
set fso= Server.CreateObject("scripting.filesystemobject")
set myfile=fso.opentextfile("C:\Documents and Settings\administrator\My documents\asp-content\fso\file.txt",2,true)
myfile.writeline("I am a man.")
End Sub
Sub Session_OnEnd()
fso.deletefile "C:\Documents and Settings\administrator\My Documents\asp-content\fso\file2.txt"
myfile.close
set fso=nothing
End Sub
</SCRIPT>