Skip to content

Instantly share code, notes, and snippets.

@dvhthomas
Created November 21, 2009 00:12
Show Gist options
  • Save dvhthomas/239899 to your computer and use it in GitHub Desktop.
Save dvhthomas/239899 to your computer and use it in GitHub Desktop.
Core Zipping interfaces
using System;
using System.IO;
namespace Woolpert.Compression
{
/// <summary>
/// Zips files up
/// </summary>
public interface IFileZipUtility
{
/// <summary>
/// Zips files from a directory and subdirectories
/// </summary>
/// <param name="zipFilePath">The name of the zipped file</param>
/// <param name="directory">directory to zip files up in</param>
void GenerateZipFile(string zipFilePath, string directory);
/// <summary>
/// Zips files from a directory and subdirectories if recursive is true
/// </summary>
/// <param name="zipFilePath">The name of the zipped file</param>
/// <param name="directory">directory to zip files up in</param>
/// <param name="recursive">Would you like to zip up subdirectories as well?</param>
void GenerateZipFile(string zipFilePath, string directory, bool recursive);
/// <summary>
/// Zips a single file in to a compressed archive
/// </summary>
/// <param name="zipFilePath">The full name of the zip file that
/// will be created, e.g., "C:\Temp\MyArchive.7z". Make
/// sure that the file extension is appropriate to the
/// archive format that you are creating, e.g., zip or 7z.
///
/// If the archive already exists then the file will be added
/// to that archive. Delete any existing files first if you
/// want a fresh archive.</param>
/// <param name="file">The file that you want to compress</param>
void GenerateZipFile(string zipFilePath, FileInfo file);
/// <summary>
/// Unzips all of the contents of a compressed archive
/// to a single directory
/// </summary>
/// <param name="zipFilePath">The full name of the zip file
/// that you want to uncompress, e.g., "C:\Temp\MyArchive.7z"</param>
/// <param name="outputDirectory">An existing directory
/// to which all the contents of the <paramref name="zipFilePath"/>
/// will be extracted.</param>
void Unzip(string zipFilePath, string outputDirectory);
}
}
using System.IO;
namespace Woolpert.Compression
{
/// <summary>
/// Zips up files and folders
/// </summary>
public interface IZip
{
/// <summary>
/// Generates zip files
/// </summary>
/// <param name="zipFilePath">Path of zip file to create</param>
/// <param name="directoryToZip">The top level directory to zip up</param>
/// <param name="recursive">Would you like to zip up subdirectories as well?</param>
void GenerateZipFile(string zipFilePath, string directoryToZip, bool recursive);
/// <summary>
/// Extracts files from a zip archive
/// </summary>
/// <param name="zipFile">Path of the zip file to create or overwrite</param>
/// <param name="directoryToUnzipTo">The existing directory to put unzipped files into</param>
void UnzipZipFile(string zipFile, string directoryToUnzipTo);
/// <summary>
/// Compress a single file
/// </summary>
/// <param name="zipFilePath">The archive file to create or overwrite</param>
/// <param name="fileToCompress">The single file to compress</param>
void GenerateZipFile(string zipFilePath, FileInfo fileToCompress);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment