後來我改為登入的時候建立使用者暫存資料夾
login.asp
Fdr = "\export\"&Session("EMPLOYEECODE")&""
If DeleteFolder(Fdr) = False Then
CreateFolder(Fdr)
Else
CreateFolder(Fdr) '預防使用者關閉瀏覽器,導致暫存資料夾沒有正常被刪除,故先刪除舊資料,在建立新資料夾
End If
然後登出logout.asp 或者 Session.Timeout 時,觸發Session_OnEnd刪除此資料夾
Global.asa
<script language="vbscript" runat="server">
Sub Application_OnStart
Application("Fdr") = Server.MapPath("\export\")
End Sub
Sub Session_OnEnd
Application.Lock
Fdr = Application("Fdr")& "\" & session("EMPLOYEECODE")
Application.UnLock
'刪除使用者暫存資料夾
Set Fso = Server.CreateObject("Scripting.FileSystemObject" )
If Fso.FolderExists(Fdr) Then '若資料夾存在,則刪除資料夾
Fso.Deletefolder Fdr,true
End If
Set Fso = Nothing
End Sub
</script>
這樣就完成我要的功能了,謝謝各位前輩!