Binary System | skills | data | database
Yesterday, an outdated friend gave, a station of all the files and pictures in a binary way into the database, with the following code can be used to restore the database files and pictures.
Change the resulting database name to Tomdb.mdb, and then save the following code in the VBS format. Put it in the same directory, execute the VBS file
Dim RS, WS, FSO, Conn, stream, ConnStr, Thefolder
Set rs = CreateObject ("ADODB.") RecordSet ")
Set stream = CreateObject ("ADODB.") Stream ")
Set conn = CreateObject ("ADODB. Connection ")
Set fso = CreateObject ("Scripting.FileSystemObject")
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=tomdb.mdb;"
Conn. Open ConnStr
Rs. Open "WZ", Conn, 1, 1
Stream. Open
Stream. Type = 1
On Error Resume Next
Do Until Rs. Eof
Thepath = rs ("folder") & "\"
Thefolder = Left (Thepath, InStrRev (thepath, "\"))
If FSO. FolderExists (Thefolder) = False Then
CreateFolder (Thefolder)
End If
Stream. SetEOS ()
Stream. Write RS ("body")
Stream. SaveToFile Str & thepath & RS ("file"), 2
Rs. MoveNext
Loop
Rs. Close
Conn. Close
Stream. Close
Set ws = Nothing
Set rs = Nothing
Set stream = Nothing
Set conn = Nothing
WScript.Echo "All Files released!"
Sub 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))
End If
If InStr (Mid (thepath, i + 1), "\") Then
i = i + Instr (Mid (thepath, i + 1), "\")
Else
i = 0
End If
Loop
End Sub