Ejemplo n.º 1
0
        public static void CompressDirectory(string directoryPath, string archivePath, string archiveName, bool deleteDirectory=false)
        {
            string archivefile = Path.Combine(archivePath, archiveName);
            Directory.CreateDirectory(archivePath);

            string[] files = Directory.GetFiles(directoryPath);

            using (var def = new UZipDotNet.DeflateZipFile(@archivefile))
            {
                foreach (string file in files)
                {
                    string fileName = Path.GetFileName(file);
                    def.Compress(file, fileName);
                }
                def.Save();
            }

            if(deleteDirectory)
                Directory.Delete(directoryPath, true);
        }
Ejemplo n.º 2
0
        public static void CompressDirectory(string directoryPath, string archivePath, string archiveName, bool deleteDirectory = false)
        {
            string archivefile = Path.Combine(archivePath, archiveName);

            Directory.CreateDirectory(archivePath);

            string[] files = Directory.GetFiles(directoryPath);

            using (var def = new UZipDotNet.DeflateZipFile(@archivefile))
            {
                foreach (string file in files)
                {
                    string fileName = Path.GetFileName(file);
                    def.Compress(file, fileName);
                }
                def.Save();
            }

            if (deleteDirectory)
            {
                Directory.Delete(directoryPath, true);
            }
        }