-- sZipFile - полный путь к архиву -- tFiles - таблица файлов -- sWorkPath - рабочая папка Zip.AddEx = function (sZipFile, tFiles, sWorkPath) sWorkPath = sWorkPath or ""; -------------------------------------- -- создание временной папки local sTempFolderName = ""; repeat sTempFolderName = ""; while #sTempFolderName < 7 do sTempFolderName = sTempFolderName .. String.Char(Math.Random(97, 122)); end sTempFolderName = _TempFolder.."\\~"..sTempFolderName..".tmp"; until not Folder.DoesExist(sTempFolderName); if not Folder.DoesExist(sTempFolderName) then Folder.Create(sTempFolderName); end -------------------------------------- local tPaths, sNewPath, sFolder for i = 1, #tFiles do if File.DoesExist(tFiles[i]) then tPaths = String.SplitPath(tFiles[i]); if sWorkPath ~= "" then if String.Right(sWorkPath, 1) ~= "\\" then sWorkPath = sWorkPath .. "\\"; end sFolder = String.Mid(tPaths.Drive..tPaths.Folder, #sWorkPath + 1, -1); else sFolder = String.TrimLeft(tPaths.Folder, "\\"); end sNewPath = sTempFolderName.."\\"..sFolder; Folder.Create(sNewPath); File.Copy(tFiles[i], sNewPath, false, true, false, false, nil); end end Zip.Add(sZipFile, {sTempFolderName.."\\*.*"}, true, "", 5, nil, true); Folder.DeleteTree(sTempFolderName, nil); end t = TextFile.ReadToTable("C:\\1.txt"); Zip.AddEx("C:\\123.zip", t, "C:\\Program Files\\Internet Explorer"); |