<% Function Er() '错误处理
If Err.Number = 0 Then
Er = False
Else
Err.Clear
Er = True
End If
End Function
sub delfile(FileName) '这是一个用于删除文件的过程,如未指定文件名,将删除该目录下所有文件
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) '这是一个用于写文本文件的过程
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) '这是一个用于检测一个文件是否存在的函数
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) '这是一个用于读出文本文件的函数
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
%>