Click here to Skip to main content
15,886,799 members
Articles / General Programming / Threads

SimplePack Library

Rate me:
Please Sign up or sign in to vote.
4.93/5 (30 votes)
23 Nov 2010CPOL7 min read 72.6K   1.9K   97  
Simple way how to pack data into one file
using System;
using System.ComponentModel;
using SimplePack.Exceptions;

namespace SimplePack.Events
{
    ///<summary>
    /// Delegate which wrap <see cref="ExtractFileCompletedEventArgs"/> event argument.
    ///</summary>
    ///<param name="sender"></param>
    ///<param name="extractFileCompletedEventArgs"></param>
    public delegate void ExtractFileCompletedEventHandler(
        Archive sender, ExtractFileCompletedEventArgs extractFileCompletedEventArgs);

    ///<summary>
    /// Asynchronous Event Argument which is invoked when extracting file from Archive is done.
    ///</summary>
    public class ExtractFileCompletedEventArgs : AsyncCompletedEventArgs
    {
        private readonly string newFilePath;
        private readonly string fileArchivePath;

        ///<summary>
        /// Constructor.
        ///<list type="table">
        /// <listheader>
        /// <term>Exceptions in Error</term>
        /// <description>Conditions</description>
        /// </listheader>
        ///<item>
        /// <term><see cref="UnauthorizedAccessException"/></term>
        /// <description>you don't have privileges to write to specified directory</description>
        ///</item>
        ///<item>
        /// <term><see cref="ArchivePathException"/></term>
        /// <description><paramref name="fileArchivePath"/> is not correct</description>
        ///</item> 
        ///<item>
        /// <term><see cref="ArchiveFileNotFoundException"/></term>
        /// <description>archive path is syntactically correct but File not exist in archive</description>
        ///</item>
        ///<item>
        /// <term><see cref="ArchiveConsistencyException"/></term>
        /// <description>extracted file have different size than expected</description>
        ///</item>
        ///<item>
        /// <term><see cref="ArchiveNotOpenedException"/></term>
        /// <description>Archive must be opened first</description>
        ///</item>
        ///</list>
        ///</summary>
        ///<param name="newFilePath">File Path where File will be extracted</param>
        ///<param name="fileArchivePath">File Path in Archive specified which File will be extracted</param>
        ///<param name="error">Exception occurred during performing asynchronous operation</param>
        ///<param name="canceled"><see langword="true"/> if operation was canceled (unused)</param>
        ///<param name="userState">unused</param>
        public ExtractFileCompletedEventArgs(string newFilePath, string fileArchivePath, Exception error, bool canceled, object userState)
            : base(error, canceled, userState)
        {
            this.newFilePath = newFilePath;
            this.fileArchivePath = fileArchivePath;
        }

        ///<summary>
        /// File Path where File will be extracted.
        ///</summary>
        public string NewFilePath
        {
            get { return newFilePath; }
        }

        ///<summary>
        /// File Path in Archive specified which File will be extracted.
        ///</summary>
        public string FileArchivePath
        {
            get { return fileArchivePath; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Slovakia Slovakia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions