当前位置: 首页>>代码示例>>C#>>正文


C# ZipFile.GetEnumerator方法代码示例

本文整理汇总了C#中ZipFile.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.GetEnumerator方法的具体用法?C# ZipFile.GetEnumerator怎么用?C# ZipFile.GetEnumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZipFile的用法示例。


在下文中一共展示了ZipFile.GetEnumerator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractZip

        /// <summary>
        /// Extract the contents of a zip file.
        /// </summary>
        /// <param name="zipFileName">The zip file to extract from.</param>
        /// <param name="targetDirectory">The directory to save extracted information in.</param>
        /// <param name="overwrite">The style of <see cref="Overwrite">overwriting</see> to apply.</param>
        /// <param name="confirmDelegate">A delegate to invoke when confirming overwriting.</param>
        /// <param name="fileFilter">A filter to apply to files.</param>
        /// <param name="directoryFilter">A filter to apply to directories.</param>
        /// <param name="restoreDateTime">Flag indicating wether to restore the date and time for extracted files.</param>
        public void ExtractZip(string zipFileName, string targetDirectory, 
            Overwrite overwrite, ConfirmOverwriteDelegate confirmDelegate,
            string fileFilter, string directoryFilter, bool restoreDateTime)
        {
            if ( (overwrite == Overwrite.Prompt) && (confirmDelegate == null) ) {
                throw new ArgumentNullException("confirmDelegate");
            }

            continueRunning_ = true;
            overwrite_ = overwrite;
            confirmDelegate_ = confirmDelegate;
            targetDirectory_ = targetDirectory;
            fileFilter_ = new NameFilter(fileFilter);
            directoryFilter_ = new NameFilter(directoryFilter);
            restoreDateTimeOnExtract_ = restoreDateTime;

            using ( zipFile_ = new ZipFile(zipFileName) ) {

            #if !NETCF_1_0
                if (password_ != null) {
                    zipFile_.Password = password_;
                }
            #endif

                System.Collections.IEnumerator enumerator = zipFile_.GetEnumerator();
                while ( continueRunning_ && enumerator.MoveNext()) {
                    ZipEntry entry = (ZipEntry) enumerator.Current;
                    if ( entry.IsFile )
                    {
                        if ( directoryFilter_.IsMatch(Path.GetDirectoryName(entry.Name)) && fileFilter_.IsMatch(entry.Name) ) {
                            ExtractEntry(entry);
                        }
                    }
                    else if ( entry.IsDirectory ) {
                        if ( directoryFilter_.IsMatch(entry.Name) && CreateEmptyDirectories ) {
                            ExtractEntry(entry);
                        }
                    }
                    else {
                        // Do nothing for volume labels etc...
                    }
                }
            }
        }
开发者ID:Titaye,项目名称:SLExtensions,代码行数:54,代码来源:FastZip.cs


注:本文中的ZipFile.GetEnumerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。