_PHYSICAL_PATH")&;file
Set fso = nothing
End Function
'=========================================================
'◆ 备份指定文件 ◆
'=========================================================
Function CopyFile(oldfile,newfile)
Set fso = CreateObject(FSObject)
On Error Resume Next
Set fso=Server.CreateObject(FSObject)
oldfile=Server.MapPath(oldfile)
if Err.Number>0 Then call alert("原路径错误!","")
newfile=Server.MapPath(newfile)
if Err.Number>0 Then call alert("新路径错误!","")
fso.CopyFile oldfile,newfile'覆盖原来的文件
if Err.Number>0 Then call alert(Err.Description,"")
Set fso=nothing
End Function
'=========================================================
'◆ 转移指定文件 ◆
'=========================================================
Function MoveFile(oldfile,newfile)
Set fso = CreateObject(FSObject)
On Error Resume Next
Set fso=Server.CreateObject(FSObject)
oldfile=Server.MapPath(oldfile)
if Err.Number>0 Then call alert("原路径错误!","")
newfile=Server.MapPath(newfile)
if Err.Number>0 Then call alert("新路径错误!","")
'fso.MoveFile oldfile,newfile'不能覆盖原来的文件
fso.MoveFile "d:\o\data\test.txt","d:\o\databackup\test3.txt"
if Err.Number>0 Then call alert(Err.Description,"")
Set fso=nothing
End Function
'=========================================================
'◆ 读取文件代码 ◆
'=========================================================
Function loadfile(file)'读取文件
dim ftemp
Set fso = CreateObject(FSObject)
Set ftemp=fso.OpenTextFile(Server.MapPath(""&;file&;""), 1)
loadfile=ftemp.ReadAll
ftemp.Close
fso.close
set fso=nothing
End Function
'=========================================================
'◆ 根据代码生成文件 ◆
'=========================================================
'========================================
'■file生成文件名
'■code文件的代码
'========================================
Function savefile(file,code)'保存文件
dim MyFile
Set fso = CreateObject(FSObject)
Set MyFile = fso.CreateTextFile(Server.mapPath(file), True)
MyFile.WriteLine(code)
MyFile.Close
set MyFile=nothing
End Function
'=========================================================
'◆ 压缩数据库 ◆
'=========================================================
'========================================
'■dbPath数据文件路径
'■boolIs97 access97
压缩 '========================================
Function CompactDB(dbPath,boolIs97)
dim strDBPath,fso,Engine
dbPath=server.mappath(dbpath)
strDBPath = left(dbPath,instrrev(DBPath,"\"))
Set fso = CreateObject(FSObject)
If fso.FileExists(dbPath) Then
Set Engine = CreateObject("JRO.JetEngine")
If boolIs97 = "True" Then
dim JET_3X
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &; dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &; strDBPath &; "temp.mdb;" _
&;"Jet OLEDB:Engine Type=" &; JET_3X
Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &; dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database pass
word="&;dbpw&;";Data Source="&;strDBPath&;"temp.mdb"
End If
fso.CopyFile strDBPath &; "temp.mdb",dbpath
fso.DeleteFile(strDBPath&;"temp.mdb")
Set fso = nothing
Set Engin