Esempio n. 1
0
        public void CompressFile(ZipMode zipMode)
        {
            using (ZipService zipService = new ZipService())
            {
                if (zipMode == ZipMode.zip)
                {
                    compressedStdfPath = stdfPath + ".zip";
                    zipService.CompressFile(stdfPath, compressedStdfPath, "zip");

                    compressedMTcsvPath = mtcsvPath + ".zip";
                    zipService.CompressFile(mtcsvPath, compressedMTcsvPath, "zip");
                }
                else if (zipMode == ZipMode.gz)
                {
                    compressedStdfPath = stdfPath + ".gz";
                    zipService.CompressFile(stdfPath, compressedStdfPath, "gzip");

                    compressedMTcsvPath = mtcsvPath + ".gz";
                    zipService.CompressFile(mtcsvPath, compressedMTcsvPath, "gzip");
                }
                else if (zipMode == ZipMode.tgz)
                {
                    string tarPath = stdfPath + ".tar";
                    zipService.CompressFile(stdfPath, tarPath, "tar");
                    compressedStdfPath = tarPath + ".gz";
                    zipService.CompressFile(tarPath, compressedStdfPath, "gzip");

                    tarPath = mtcsvPath + ".tar";
                    zipService.CompressFile(mtcsvPath, tarPath, "tar");
                    compressedMTcsvPath = tarPath + ".gz";
                    zipService.CompressFile(tarPath, compressedMTcsvPath, "gzip");
                }
            }
        }
Esempio n. 2
0
        public void DecompressFile(string zipFilePath)
        {
            using (ZipService zipService = new ZipService())
            {
                if (Path.GetExtension(zipFilePath) == ".gz")
                {
                    zipService.DecompressFileToDestDirectory(zipFilePath, Path.GetDirectoryName(zipFilePath));

                    zipService.DecompressFileToDestDirectory(zipFilePath.Remove(zipFilePath.Length - 3, 3), Path.GetDirectoryName(zipFilePath));
                }
                else if (Path.GetExtension(zipFilePath) == ".zip")
                {
                    zipService.DecompressFileToDestDirectory(zipFilePath, Path.GetDirectoryName(zipFilePath));
                }
                else
                {
                    throw new Exception("Unsupported compressed type, please contact developer!");
                }
            }
        }