Used technology: C # , IonicZip library .
From a list of several log files (say 10,000, each of a reasonable size). I have to pin these files to a folder. But then the size of the ZIP archive should be approximately below 4 MB. How can I have as few zip folders as possible.
private static string ZipAndReturnFolderPath(IEnumerable<string> files, string saveToFolder)
{
int listToSkip = 0;
using (var zip = new ZipFile())
{
do
{
zip.AddFiles(files.Skip(listToSkip * 10).Take(10));
zip.Save(saveToFolder);
listToSkip++;
}
while ((new FileInfo(saveToFolder).Length < _lessThan4MB) && totalFilesRemaining > 0);
}
return saveToFolder;
}
Here, to make it concise, I deleted a few lines of code. Parameter: files - contains the path to the total number of remaining files that should be archived (do not worry about how I will support this). saveToFolder is the destination for the zipped folder (this will be unique every time the function is called).
, . , , . , , , , .
- ?