解包程序:
<%
'On Error Resume Next
Server.ScriptTimeOut = 300
Dim Fso, Rs, Stream, Conn '定义需要的组件
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Rs = CreateObject("ADODB.RecordSet")
Set Stream = CreateObject("ADODB.Stream")
Set Conn = CreateObject("ADODB.Connection")
UnPackMdb Server.MapPath("DataPack.mdb")
Response.End
'------------------------------------------------------------------
Function CreateFolder(ThePath) '创建文件夹
Dim i
i = InStr(ThePath, "\")
Do While i > 0
If Fso.FolderExists(Left(ThePath, i)) = False Then Fso.CreateFolder(Left(ThePath, i - 1))
If InStr(Mid(ThePath, i + 1), "\") Then
i = i + InStr(Mid(ThePath, i + 1), "\")
Else
i = 0
End If
Loop
End Function
'------------------------------------------------------------------
Function UnPackMdb(TheMdb)
Dim Str, TheFolder
Str = Server.MapPath("") & "\"
If Fso.FileExists(TheMdb) = False Then
Response.Write "数据库:" & TheMdb & " 不存在!"
Response.end
End IF
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & TheMdb & ";"
Rs.Open "FileData", Conn, 1, 1
Stream.Open
Stream.Type = 1
Do Until Rs.Eof
TheFolder = Left(Rs("ThePath"), InStrRev(Rs("ThePath"), "\"))
If Fso.FolderExists(Str & TheFolder) = False Then
CreateFolder(Str & TheFolder)
End If
Stream.SetEos()
If len(Rs("FileContent")) <> 0 Then
Stream.Write Rs("FileContent")
End If
Stream.SaveToFile Str & Rs("ThePath"), 2
Rs.MoveNext
Loop
Stream.Close
Rs.Close
Conn.Close
'If Fso.FileExists(TheMdb) Then Fso.DeleteFile TheMdb,True '删除旧的数据库文件
Response.Write "所有文件释放完毕! 完成时间:" & Now()
End Function
%> |