本文整理汇总了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));
}
示例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();
}
}
示例3: AddFilesToZip
public static void AddFilesToZip(string zipPath, List<string> files)
{
var v = new Ionic.Zip.ZipFile(zipPath);
v.AddFiles(files);
v.Save();
}
示例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);
}
}
示例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);
}
示例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();
}
示例7: CompressFiles
public static void CompressFiles(IEnumerable<string> filesPaths, string compressedFilePath)
{
using (var zip = new ZipFile())
{
zip.AddFiles(filesPaths, false, "");
zip.Save(compressedFilePath);
}
}
示例8: CreateArchive
private void CreateArchive(Stream outputStream)
{
using (var zip = new ZipFile())
{
zip.AddFiles(EnumerateLogFiles(GetStartDate(), GetEndDate()), true, "");
zip.Save(outputStream);
}
}
示例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);
}
}
示例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();
}
}
示例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");
}
示例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();
}
示例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;
}
示例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));
}
}
}
示例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;
}