Ejemplo n.º 1
0
        ///// <summary>
        ///// De-compress the file.
        ///// </summary>
        ///// <param name="fileInfo">The file information.</param>
        ///// <param name="destinationPath">The destination path.</param>
        ///// <param name="deCompressed">The de compressed.</param>
        ///// <returns>True if successful</returns>
        public static bool DeCompressFile(this FileInfo fileInfo, string destinationPath, out DeCompressedElement deCompressed)
        {
            bool success;
            ICompression compression;
            switch (fileInfo.Extension.ToLower())
            {
                case "gz":
                    compression = new GZipCompression();
                    success = compression.DeCompressFile(fileInfo.FullName, destinationPath, out deCompressed);
                    break;
                case "zip":
                    compression = new ZipCompression();
                    success = compression.DeCompressFile(fileInfo.FullName, destinationPath, out deCompressed);
                    break;
                case "ziparc":
                    compression = new ZipArchiveCompression();
                    success = compression.DeCompressFile(fileInfo.FullName, destinationPath, out deCompressed);
                    break;
                default:
                    success = false;
                    deCompressed = null;
                    break;

            }
            return success;
        }
Ejemplo n.º 2
0
        ///// <summary>
        ///// De-compress the file.
        ///// </summary>
        ///// <param name="fileInfo">The file information.</param>
        ///// <param name="destinationPath">The destination path.</param>
        ///// <param name="deCompressed">The de compressed.</param>
        ///// <returns>True if successful</returns>
        public static bool DeCompressFile(this FileInfo fileInfo, string destinationPath, out DeCompressedElement deCompressed)
        {
            bool         success;
            ICompression compression;

            switch (fileInfo.Extension.ToLower())
            {
            case "gz":
                compression = new GZipCompression();
                success     = compression.DeCompressFile(fileInfo.FullName, destinationPath, out deCompressed);
                break;

            case "zip":
                compression = new ZipCompression();
                success     = compression.DeCompressFile(fileInfo.FullName, destinationPath, out deCompressed);
                break;

            case "ziparc":
                compression = new ZipArchiveCompression();
                success     = compression.DeCompressFile(fileInfo.FullName, destinationPath, out deCompressed);
                break;

            default:
                success      = false;
                deCompressed = null;
                break;
            }
            return(success);
        }