예제 #1
0
        string ZipFileToALocalTempFile(IActivityIOOperationsEndPoint src, IDev2ZipOperationTO args)
        {
            var packFile     = src.IOPath.Path;
            var tempFileName = CreateTmpFile();

            if (src.RequiresLocalTmpStorage())
            {
                var tempDir = _common.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))
                {
                    _fileWrapper.WriteAllBytes(tmpFile, s.ToByteArray());
                }
            }

            using (var zip = new ZipFile())
            {
                if (args.ArchivePassword != string.Empty)
                {
                    zip.Password = args.ArchivePassword;
                }
                zip.CompressionLevel = _common.ExtractZipCompressionLevel(args.CompressionRatio);
                zip.AddFile(packFile, ".");
                zip.Save(tempFileName);
            }

            return(tempFileName);
        }