Exemple #1
0
 private void ZipAllFiles(string rootPath, string tempZipPath)
 {
     var zipService = new ZipService();
     zipService.OpenZipFile(tempZipPath);
     ZipDirectory(zipService, rootPath, "root");
     zipService.CloseZipFile();
 }
Exemple #2
0
        private void ZipDirectory(ZipService zipService, string directoryPath, string relativePath)
        {
            var dirInfo = new DirectoryInfo(directoryPath);

            foreach (var file in dirInfo.GetFiles())
            {
                if (!file.Name.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
                {
                    zipService.AddFileToZip(file.FullName, relativePath);
                }
            }

            foreach (var childDirInfo in dirInfo.GetDirectories())
            {
                var childPath = string.Format("{0}\\{1}", relativePath, childDirInfo.Name);
                ZipDirectory(zipService, childDirInfo.FullName, childPath);
            }
        }