<% Function Er () ' Error handling
If Err.Number = 0 Then
Er = False
Else
Err.Clear
Er = True
End If
End Function
Sub Delfile (filename) ' This is a procedure for deleting files, and if no file name is specified, all files in that directory will be deleted
On Error Resume Next
Set Fs=createobject ("Scrip" & "Ting.filesys" & "Temob" & "Ject")
If InStr (FileName, ":") <>0 Then
Path=filename
Else
Path=server. MapPath (FileName)
End If
' Response.Write Path
Fs.deletefile Path,true
Set ts=nothing
End Sub
Sub Savetext (filename,data) ' This is a process for writing text files
Set Fs=createobject ("Scrip" & "Ting.filesys" & "Temob" & "Ject")
If InStr (FileName, ":") <>0 Then
Path=filename
Else
Path=server. MapPath (FileName)
End If
Set Ts=fs.createtextfile (path,true)
Ts.writeline (data)
Ts.close
Set ts=nothing
Set fs=nothing
End Sub
function testfile (FileName) ' This is a functions to detect whether a file exists
On Error Resume Next
Set Fs=createobject ("Scrip" & "Ting.filesys" & "Temob" & "Ject")
If InStr (FileName, ":") <>0 Then
Path=filename
Else
Path=server. MapPath (FileName)
End If
Pa=fs. GETFILE (PATH)
Set fs=nothing
If ER () then
Testfile=false
Else
Testfile=true
End If
End Function
function ReadText (FileName) ' This is a functions for reading text files
On Error Resume Next
Set Adf=server. CreateObject ("Ado" & "db". Str "&" Eam ")
If InStr (FileName, ":") <>0 Then
Path=filename
Else
Path=server. MapPath (FileName)
End If
With ADF
' Response.Write Path
. type=2
. Lineseparator=13
. Open
. LoadFromFile (PATH)
. charset= "GB2312"
. position=2
readtext=. ReadText
. Cancel ()
. Close ()
End With
Set adf=nothing
End Function
%>