当前位置: 首页>>代码示例>>C#>>正文


C# ZipFile.AddFiles方法代码示例

本文整理汇总了C#中Ionic.Zip.ZipFile.AddFiles方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.AddFiles方法的具体用法?C# ZipFile.AddFiles怎么用?C# ZipFile.AddFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ionic.Zip.ZipFile的用法示例。


在下文中一共展示了ZipFile.AddFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: backupSSF

        public static void backupSSF()
        {
            //verifica se existe o diretório, caso não exista será criado
            string dirAnteriores = Library.appDir + "\\ssf\\anteriores\\";
            if (!System.IO.Directory.Exists(dirAnteriores))
            {
                System.IO.Directory.CreateDirectory(dirAnteriores);
            }

            //verifica se existe o diretório, caso não exista será criado
            string dirZipados = Library.appDir + "\\ssf\\zipados\\";
            if (!System.IO.Directory.Exists(dirZipados))
            {
                System.IO.Directory.CreateDirectory(dirZipados);
            }

            //backup ssf
            System.IO.DirectoryInfo dirSSF = new System.IO.DirectoryInfo(appDir + "\\ssf");

            string[] filePaths = System.IO.Directory.GetFiles(dirSSF.ToString(), "*.ssf");

            ZipFile zip =
                new ZipFile(dirZipados + DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year +
                    DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".zip");
            zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
            zip.AddFiles(filePaths);
            zip.Save();

            //move todos os arquivos
            foreach (string file in filePaths)
                System.IO.File.Move(file, dirAnteriores + System.IO.Path.GetFileName(file));
        }
开发者ID:alphaman8,项目名称:CIP_beta1,代码行数:32,代码来源:Library.cs

示例2: Serialize

        /// <summary>
        /// Serialize
        /// </summary>
        /// <param name="site">site</param>
        /// <param name="path">path</param>
        /// <returns></returns>
        public void Serialize(Site site, string path)
        {
            if (site == null)
            {
                throw new ArgumentException("site");
            }
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentException("stream");
            }

            var tempPath = Path.GetTempPath() + "site.xml";
            using (var stream = File.Create(tempPath))
            {
                var serializer = new XmlSerializer(typeof(Site));
                serializer.Serialize(stream, site);
            }

            var packagePath = path + Path.DirectorySeparatorChar + site.Name + ".wbp";
            if (File.Exists(packagePath))
            {
                File.Delete(packagePath);

            }
            using (ZipFile package = new ZipFile(packagePath, Console.Out))
            {
                package.AddFile(tempPath, string.Empty);
                package.AddFiles(site.Resources.Select(r => r.TextData).Where(File.Exists), "resources");
                package.Save();
            }
        }
开发者ID:WebCentrum,项目名称:WebPackUI,代码行数:37,代码来源:SiteSerializer.cs

示例3: AddFilesToZip

    public static void AddFilesToZip(string zipPath, List<string> files)
    {
        var v = new Ionic.Zip.ZipFile(zipPath);

        v.AddFiles(files);
        v.Save();
    }
开发者ID:iansaviour,项目名称:SE-chat-bot-app-3,代码行数:7,代码来源:Helper.cs

示例4: doBackup

        public static void doBackup()
        {
            try {
                List<string> bkpfiles = new List<string>();
                DateTime fecha = DateTime.Now;
                string format = "yyyyMMdd";    // Use this format
                String[] pacientes = Directory.GetFiles(Configuracion.getDirectorioPacientes(),"*.dat");
                String[] hhcc = Directory.GetFiles(Configuracion.getDirectorioHC() ,"*.dat");
                String[] imagenes = Directory.GetFiles(Configuracion.getDirectorioImagenes());
                foreach(string s in pacientes)
                    bkpfiles.Add(s);
                foreach(string s in hhcc)
                    bkpfiles.Add(s);
                foreach(string s in imagenes)
                    bkpfiles.Add(s);
                String backupfile = Configuracion.getDirectorioBackup() + "\\" + "Backup_" + fecha.ToString(format) + ".zip";
                ZipFile zip = new ZipFile();
                zip.AddFiles(bkpfiles.ToArray());
                zip.Save(backupfile);
                MessageBox.Show("Backup realizado correctamente.\n" + backupfile);

            } catch (Exception e) {
                MessageBox.Show("Error en el proceso de backup!\n" + e.Message);
            }
        }
开发者ID:juanmariaarce,项目名称:Consultorio,代码行数:25,代码来源:Backup.cs

示例5: Generate

        /// <summary>
        /// This method generates the cbz file from the images in the manga book.
        /// </summary>
        /// <param name="mangaBook"></param>
        /// <param name="saveLocation">Location to save the manga book cbz file.</param>
        public void Generate(MangaBook mangaBook, string saveLocation)
        {
            OperationStatus.StartedMangaBookFileCreation(mangaBook);

            Collection<string> imageSaveLocationList = new Collection<string>();

            mangaBook.SaveLocationPath = Path.Combine(saveLocation, mangaBook.FileName());
            using (ZipFile zip = new ZipFile(mangaBook.SaveLocationPath))
            {
                SavePagesAsPhysicalFiles(mangaBook, saveLocation, imageSaveLocationList);

                // Get all pages from save location and create cbz file.

                zip.AddFiles(imageSaveLocationList);
                zip.Save();

                // Delete the temporary files.

                foreach (string path in imageSaveLocationList)
                {
                    File.Delete(path);
                }
            }

            OperationStatus.CompletedMangaBookFileCreation(mangaBook);
        }
开发者ID:slowmonkey,项目名称:MangaMaker,代码行数:31,代码来源:ComicBookZipFileSerialiser.cs

示例6: CreateArchive

        private static void CreateArchive(IEnumerable<JobInfo> jobs, string archiveFile)
        {
            File.Delete(archiveFile);

              var zipper = new ZipFile(archiveFile);
              zipper.AddFiles(jobs.Select(it => it.ImageFile));
              zipper.Save();
        }
开发者ID:njmube,项目名称:public,代码行数:8,代码来源:Program.cs

示例7: CompressFiles

		public static void CompressFiles(IEnumerable<string> filesPaths, string compressedFilePath)
		{
			using (var zip = new ZipFile())
			{
				zip.AddFiles(filesPaths, false, "");
				zip.Save(compressedFilePath);
			}
		}
开发者ID:w01f,项目名称:VolgaTeam.SalesLibrary,代码行数:8,代码来源:Utils.cs

示例8: CreateArchive

 private void CreateArchive(Stream outputStream)
 {
     using (var zip = new ZipFile())
     {
         zip.AddFiles(EnumerateLogFiles(GetStartDate(), GetEndDate()), true, "");
         zip.Save(outputStream);
     }
 }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:8,代码来源:LogHelper.ascx.cs

示例9: ExecuteResult

 public override void ExecuteResult(ControllerContext context)
 {
     using (ZipFile zf = new ZipFile())
     {
         zf.AddFiles(_files, false, "");
         context.HttpContext.Response.ContentType = "application/zip";
         context.HttpContext.Response.AppendHeader("content-disposition", "attachment; filename=" + FileName);
         zf.Save(context.HttpContext.Response.OutputStream);
     }
 }
开发者ID:BoyZeePoole,项目名称:KnowledgeBox,代码行数:10,代码来源:ZipResult.cs

示例10: Main

 static void Main(string[] args)
 {
     using (ZipFile zip = new ZipFile())
     {
         string[] files = Directory.GetFiles(@".");
         files = (from o in files where !o.Contains(".z") && !o.Contains("zip.exe") select o).ToArray();
         zip.AddFiles(files);
         zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G");
         zip.MaxOutputSegmentSize = 99 * 1024 * 1024;   // 2mb
         zip.Save("zip.zip");
         //Console.ReadLine();
     }
 }
开发者ID:dioptre,项目名称:nkd,代码行数:13,代码来源:Program.cs

示例11: Zip_Attachments

 /// <summary>
 /// zips attachments, takes parameters directly from the "files" list
 /// </summary>
 public void Zip_Attachments(object sender, RoutedEventArgs e)
 {
     zipProgressBar.Visibility = Visibility.Visible;
     zipProgressOverlay.Visibility = Visibility.Visible;
     SendMailTab_message.IsEnabled = false;
     SendMailTab_subject.IsEnabled = false;
     SendMailTab_to.IsEnabled = false;
     zipProgressBar.Value = 0;
     zipProgressBar.Maximum = files.Count();
     ZipFile zip = new ZipFile();
     zip.AddFiles(files);
     zip.SaveProgress += zip_SaveProgress;
     Directory.CreateDirectory("Zipped");
     zip.Save("Zipped\\test.zip");
 }
开发者ID:Jesperb21,项目名称:derpmail,代码行数:18,代码来源:ZippingHandler.cs

示例12: Main

        static void Main(string[] args)
        {
            Stream outStream = new MemoryStream();
            using (ZipFile zip = new ZipFile())
            {
                string[] files = Directory.GetFiles(@"C:\ForRobot");
                zip.AddFiles(files,"");
                zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G");
                //zip.Save(@"C:\ForRobot.zip");
                zip.Save(outStream);
             }

            Console.WriteLine(outStream.Length);
            outStream.Close();
            Console.ReadLine();
        }
开发者ID:suplits,项目名称:File-and-Stream-IO,代码行数:16,代码来源:Program.cs

示例13: CrearZip

        public bool CrearZip(string pathDestino, IList<string> pathsArchivos)
        {
            bool zipped = false;

            if (pathsArchivos.Count > 0)
            {
                using (var loanZip = new ZipFile())
                {
                    //var filePath = Path.Combine()
                    loanZip.AddFiles(pathsArchivos, false, "");
                    loanZip.Save(pathDestino);
                    zipped = true;
                }
            }

            return zipped;
        }
开发者ID:pragmasolutions,项目名称:Maxikioscos,代码行数:17,代码来源:frmExportar.cs

示例14: SaveZipFile

        public void SaveZipFile(string folderPath, string fileName)
        {
            using (var zip = new ZipFile())
            {
                string zippedFilePath = this.fileSystem.Path.Combine(folderPath, fileName);

                var pdfFiles = this.fileSystem.Directory.GetFiles(folderPath, "*.pdf");
                if (pdfFiles.Any())
                {
                    zip.AddFiles(pdfFiles, @"\");
                    zip.Save(zippedFilePath);
                }
                else
                {
                    throw new Exception(string.Format("There were no PDF files that were present in directory {0}", folderPath));
                }
            }
        }
开发者ID:jhonner72,项目名称:plat,代码行数:18,代码来源:FileWriter.cs

示例15: ZipConvertedAudioFiles

        public static string ZipConvertedAudioFiles(IEnumerable<string> convertedAudioFilenames)
        {
            var zippedFileName = string.Empty;

            try
            {
                zippedFileName = FileNameGenerationHelper.GenerateFilename();
                var zip = new ZipFile(Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), zippedFileName));
                zip.AddFiles(convertedAudioFilenames.Select(caf => Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), caf)), false, "");
                zip.Save();
                zip.Dispose();
            }
            catch (Exception e)
            {
                throw new ZipException(e.Message);
            }

            return zippedFileName;
        }
开发者ID:UIKit0,项目名称:TubeToTune,代码行数:19,代码来源:FileZippingHelper.cs


注:本文中的Ionic.Zip.ZipFile.AddFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。