Пример #1
0
        /// <summary>快速解压缩</summary>
        /// <param name="fileName"></param>
        /// <param name="outputPath"></param>
        /// <param name="overrideExisting"></param>
        /// <param name="throwException"></param>
        public static void ExtractToDirectory(String fileName, String outputPath, Boolean overrideExisting = true, Boolean throwException = true)
        {
            if (fileName.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(fileName));
            }
            // 默认使用没有后缀的路径作为目录
            if (outputPath.IsNullOrEmpty())
            {
                outputPath = Path.GetDirectoryName(fileName);
            }
            if (outputPath.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(outputPath));
            }

            using var zf = new ZipFile(fileName);
            zf.Extract(outputPath, overrideExisting, throwException);
        }
Пример #2
0
        /// <summary>快速解压缩</summary>
        /// <param name="fileName"></param>
        /// <param name="outputPath"></param>
        /// <param name="overrideExisting"></param>
        /// <param name="throwException"></param>
        public static void ExtractToDirectory(String fileName, String outputPath, Boolean overrideExisting = true, Boolean throwException = true)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }
            // 默认使用没有后缀的路径作为目录
            if (String.IsNullOrEmpty(outputPath))
            {
                outputPath = Path.GetFileNameWithoutExtension(fileName);
            }
            if (String.IsNullOrEmpty(outputPath))
            {
                throw new ArgumentNullException("outputPath");
            }

            using (var zf = new ZipFile(fileName))
            {
                zf.Extract(outputPath, overrideExisting, throwException);
            }
        }