public static int ZipFiles(int packageId, string[] files, string archivePath) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(accountCheck); } // check package int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive); if (packageCheck < 0) { return(packageCheck); } // place log record TaskManager.StartTask("FILES", "ZIP_FILES", archivePath, packageId); if (files != null) { foreach (string file in files) { TaskManager.Write(file); } } try { OS.OperatingSystem os = GetOS(packageId); string zipFilePath = GetFullPackagePath(packageId, archivePath); List <string> archFiles = new List <string>(); string rootFolder = ""; foreach (string file in files) { string archFile = GetFullPackagePath(packageId, file); int idx = archFile.LastIndexOf("\\"); rootFolder = archFile.Substring(0, idx); archFiles.Add(archFile.Substring(idx + 1)); } os.ZipFiles(zipFilePath, rootFolder, archFiles.ToArray()); return(0); } catch (Exception ex) { //Log and return a generic error rather than throwing an exception TaskManager.WriteError(ex); return(BusinessErrorCodes.ERROR_FILE_GENERIC_LOGGED); } finally { TaskManager.CompleteTask(); } }