Hello Ofer,
Thank you for your code.
I have reproduced the issue you described. The example in our Help system is incorrect indeed. The PackResults routine fails during the subsequent runs, because the target archive tries to pack itself. Thank you for drawing our attention to this issue. We will fix the example. Sorry for the inconvenience.
Meanwhile, you can fix your code in one of the following ways:
1. Add a command that will delete previous runs’ packed results to your code:
function PackResults()
{
var WorkDir = Project["ConfigPath"] + "SentReports\\";
// Clears the previous run results
aqFileSystem["DeleteFolder"](WorkDir, true);
var FileName = WorkDir + "Results.mht";
Log["SaveResultsAs"](FileName, 2);
var FileList = slPacker["GetFileListFromFolder"](WorkDir);
var ArchivePath = WorkDir + "CompressedResults";
if (slPacker["Pack"](FileList, WorkDir, ArchivePath))
Log["Message"]("Files were compressed successfully.");
else
Log["Message"]("Files weren't compressed successfully.");
}
2. Place the log files to pack and the resulting archive to separate folders.
function PackResults()
{
// Specifies the folder where the files to pack reside
var WorkDir = Project["ConfigPath"] + "WorkDir\\";
// Specifies the folder where the resulting archive will be placed
var SentReports = Project["ConfigPath"] + "SentReports\\";
aqFileSystem["CreateFolder"](SentReports);
var FileName = WorkDir + "Results.mht";
Log["SaveResultsAs"](FileName, 2);
var FileList = slPacker["GetFileListFromFolder"](WorkDir);
var ArchivePath = SentReports + "CompressedResults";
if (slPacker["Pack"](FileList, WorkDir, ArchivePath))
Log["Message"]("Files were compressed successfully.");
else
Log["Message"]("Files weren't compressed successfully.");
}
Please let us know if this does not help or if you have any additional questions.
Thank you.