Skip to content

Instantly share code, notes, and snippets.

@dvhthomas
Created November 21, 2009 00:12
Show Gist options
  • Select an option

  • Save dvhthomas/239899 to your computer and use it in GitHub Desktop.

Select an option

Save dvhthomas/239899 to your computer and use it in GitHub Desktop.

Revisions

  1. dvhthomas revised this gist Nov 21, 2009. 1 changed file with 52 additions and 0 deletions.
    52 changes: 52 additions & 0 deletions IFileZipUtility.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    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);
    }
    }
  2. dvhthomas created this gist Nov 21, 2009.
    32 changes: 32 additions & 0 deletions IZip.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    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);
    }
    }