Click here to Skip to main content
15,892,965 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 73K   1.9K   97  
Simple way how to pack data into one file
using System;
using System.ComponentModel;
using System.IO;
using SimplePack.Exceptions;

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

    ///<summary>
    /// Asynchronous Event Argument which is invoked when adding file into Archive is done.
    ///</summary>
    public class AddFileCompletedEventArgs : 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="FileNotFoundException"/></term>
        /// <description><paramref name="newFilePath"/> not point to existed File</description>
        ///</item>
        ///<item>
        /// <term><see cref="ArchivePathException"/></term>
        /// <description><paramref name="fileArchivePath"/> is not correct</description>  
        ///</item> 
        ///<item>
        /// <term><see cref="ArchiveNotOpenedException"/></term>
        /// <description>Archive must be opened first</description>
        ///</item>
        ///</list>
        ///</summary>
        ///<param name="newFilePath">File Path in file-system</param>
        ///<param name="fileArchivePath">File Path in Archive. This Archive File Path is only virtual structure</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 AddFileCompletedEventArgs(string newFilePath, string fileArchivePath, Exception error, bool canceled, object userState) : base(error, canceled, userState)
        {
            this.newFilePath = newFilePath;
            this.fileArchivePath = fileArchivePath;
        }

        ///<summary>
        /// File Path in file-system.
        ///</summary>
        public string NewFilePath
        {
            get { return newFilePath; }
        }

        ///<summary>
        /// File Path in Archive. This Archive File Path is only virtual structure.
        ///</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