Do Until rs.Eof theFolder = Left(rs("path"), InStrRev(rs("path"), "\")) If fso.FolderExists(theFolder) = False Then createFolder(theFolder) End If stream.SetEos() stream.Write rs("file") stream.SaveToFile str rs("path"), 2 rs.MoveNext Loop
rs.Close conn.Close stream.Close Set ws = Nothing Set rs = Nothing Set stream = Nothing Set conn = Nothing
Wscript.Echo "所有文件释放完毕!"
Sub createFolder(path) Dim i i = Instr(path, "\") Do While i > 0 If fso.FolderExists(Left(path, i)) = False Then fso.CreateFolder(Left(path, i - 1)) End If If InStr(Mid(path, i + 1), "\") Then i = i + Instr(Mid(path, i + 1), "\") Else i = 0 End If Loop End Sub