string ZipFileToALocalTempFile(IActivityIOOperationsEndPoint src, Dev2ZipOperationTO args)
{
// normal not wild char file && not directory
var packFile = src.IOPath.Path;
var tempFileName = CreateTmpFile();
if(src.RequiresLocalTmpStorage())
{
string tempDir = CreateTmpDirectory();
var tmpFile = Path.Combine(tempDir,
src.IOPath.Path.Split(src.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries)
.Last());
packFile = tmpFile;
using(var s = src.Get(src.IOPath, _filesToDelete))
{
File.WriteAllBytes(tmpFile, s.ToByteArray());
}
}
using(var zip = new ZipFile())
{
// set password if exist
if(args.ArchivePassword != string.Empty)
{
zip.Password = args.ArchivePassword;
}
// compression ratio
zip.CompressionLevel = ExtractZipCompressionLevel(args.CompressionRatio);
// add all files to archive
zip.AddFile(packFile, ".");
zip.Save(tempFileName);
}
return tempFileName;
}