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


C# ZipFile.GetEnumerator方法代码示例

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


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

示例1: Extract

		/// <summary>
		/// Extracts the specified zip file stream.
		/// </summary>
		/// <param name="fileStream">The zip file stream.</param>
		/// <returns></returns>
		public void Extract(Stream fileStream)
		{
			_isValid = true;

			ZipFile zipFile = null;

			try
			{
				zipFile = new ZipFile(fileStream);

				IEnumerator enumerator = zipFile.GetEnumerator();

				while (enumerator.MoveNext())
				{
					ZipEntry entry = (ZipEntry)enumerator.Current;

					ExtractZipEntry(zipFile, entry);
				}
			}
			catch (Exception ex)
			{
				_isValid = false;
				_exceptionMessage = ex.Message;
			}
			finally
			{
				fileStream.Close();

				if (null != zipFile) zipFile.Close();
			}
		}
开发者ID:Christian-Xu,项目名称:ExcelDataReader,代码行数:36,代码来源:ZipWorker.cs

示例2: Load

        public Model Load(string fileName)
        {
            var document = new XmlDocument();

            if (fileName.EndsWith(".tcn"))
            {
                var file = new ZipFile(new FileStream(fileName, FileMode.Open, FileAccess.Read));

                var enumerator = file.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    if (((ZipEntry)enumerator.Current).Name.EndsWith(".xml"))
                    {
                        document.Load(file.GetInputStream((ZipEntry)enumerator.Current));
                        break;
                    }
                }
            }
            else if (fileName.EndsWith(".xml"))
                document.Load(fileName);
            else
                throw new FileLoadException();

            var tcnModel = new TCNFile();
            tcnModel.Parse(document.DocumentElement);

            return tcnModel.Convert();
        }
开发者ID:rmbzlib,项目名称:mcskin3d,代码行数:29,代码来源:ModelFormatTCN.cs

示例3: contents

 public static Map contents(ZipFile zipFile)
 {
     Map c = new Map(Sys.UriType, Sys.FileType);
       IEnumerator e = zipFile.GetEnumerator();
       while (e.MoveNext())
       {
     ZipEntry entry = (ZipEntry)e.Current;
     ZipEntryFile f = new ZipEntryFile(zipFile, entry);
     c.set(f.m_uri, f);
       }
       return c;
 }
开发者ID:nomit007,项目名称:f4,代码行数:12,代码来源:Zip.cs

示例4: ExtractZip

        /// <summary>
        /// Extract ZIP to memory
        /// </summary>
        /// <param name="inputStream"></param>
        public List<ZipEntry> ExtractZip(Stream inputStream)
        {
            using (ZipFile zip_file = new ZipFile(inputStream)) {
                System.Collections.IEnumerator enumerator = zip_file.GetEnumerator();
                while ( enumerator.MoveNext()) {
                    ZipEntry entry = (ZipEntry)enumerator.Current;

                    if (entry.IsFile)
                    {
                        ExtractEntry(entry);
                    //	ZipOutputStream zos = ((ZipFile)entry).GetOutputStream( entry );
                    }
                    else if (entry.IsDirectory) {
                        ExtractEntry(entry);
                    }
                }
            }
        }
开发者ID:hyrio,项目名称:fastxcel,代码行数:22,代码来源:FastZipExtension.cs

示例5: 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:svn2github,项目名称:awb,代码行数:54,代码来源:FastZip.cs

示例6: ExtractZip

        /// <summary>
        /// Extract the contents of a zip file held in a stream.
        /// </summary>
        /// <param name="inputStream">The seekable input stream containing the zip 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 whether to restore the date and time for extracted files.</param>
        /// <param name="isStreamOwner">Flag indicating whether the inputStream will be closed by this method.</param>
        public void ExtractZip(Stream inputStream, string targetDirectory,
                       Overwrite overwrite, ConfirmOverwriteDelegate confirmDelegate,
                       string fileFilter, string directoryFilter, bool restoreDateTime,
                       bool isStreamOwner)
        {
            if ((overwrite == Overwrite.Prompt) && (confirmDelegate == null)) {
                throw new ArgumentNullException("confirmDelegate");
            }

            continueRunning_ = true;
            overwrite_ = overwrite;
            confirmDelegate_ = confirmDelegate;
            extractNameTransform_ = new WindowsNameTransform(targetDirectory);

            fileFilter_ = new NameFilter(fileFilter);
            directoryFilter_ = new NameFilter(directoryFilter);
            restoreDateTimeOnExtract_ = restoreDateTime;

            using (zipFile_ = new ZipFile(inputStream)) {

#if !NETCF_1_0
                if (password_ != null) {
                    zipFile_.Password = password_;
                }
#endif
                zipFile_.IsStreamOwner = isStreamOwner;
                IEnumerator enumerator = zipFile_.GetEnumerator();
                while (continueRunning_ && enumerator.MoveNext()) {
                    ZipEntry entry = (ZipEntry)enumerator.Current;
                    if (entry.IsFile)
                    {
                        // TODO Path.GetDirectory can fail here on invalid characters.
                        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:ImaginationSydney,项目名称:flashdevelop,代码行数:58,代码来源:FastZip.cs

示例7: 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, string fileFilter, string directoryFilter)
        {
            continueRunning_ = true;
            extractNameTransform_ = new WindowsNameTransform(targetDirectory);

            fileFilter_ = new NameFilter(fileFilter);
            directoryFilter_ = new NameFilter(directoryFilter);

            using (zipFile_ = new ZipFile(zipFileName))
            {
                IEnumerator enumerator = zipFile_.GetEnumerator();
                while (continueRunning_ && enumerator.MoveNext())
                {
                    var entry = (ZipEntry) enumerator.Current;
                    if (entry.IsFile)
                    {
                        // TODO Path.GetDirectory can fail here on invalid characters.
                        if (directoryFilter_.IsMatch(Path.GetDirectoryName(entry.Name)) &&
                            fileFilter_.IsMatch(entry.Name))
                        {
                            ExtractEntry(entry);
                        }
                    }
                }
            }
        }
开发者ID:rxantos,项目名称:tesv-snip,代码行数:36,代码来源:FastZip.cs

示例8: Extract

		/// <summary>
		/// Extracts the specified zip file stream.
		/// </summary>
		/// <param name="fileStream">The zip file stream.</param>
		/// <returns></returns>
		public bool Extract(Stream fileStream)
		{
			if (null == fileStream) return false;

			CleanFromTemp(false);

			NewTempPath();

			_isValid = true;

			ZipFile zipFile = null;

			try
			{
				zipFile = new ZipFile(fileStream);

				IEnumerator enumerator = zipFile.GetEnumerator();

				while (enumerator.MoveNext())
				{
					ZipEntry entry = (ZipEntry)enumerator.Current;

					ExtractZipEntry(zipFile, entry);
				}
			}
			catch (Exception ex)
			{
				_isValid = false;
				_exceptionMessage = ex.Message;

				CleanFromTemp(true); //true tells CleanFromTemp not to raise an IO Exception if this operation fails. If it did then the real error here would be masked
				
			}
			finally
			{
				fileStream.Close();

				if (null != zipFile) zipFile.Close();
			}

			return _isValid ? CheckFolderTree() : false;
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:47,代码来源:ZipWorker.cs

示例9: Load

 public static List<DEngine> Load(string fileName, UndoRedoArea undoRedoArea, out DPoint pageSize, out BackgroundFigure bf, string[] extraEntryDirs, out Dictionary<string, byte[]> extraEntries)
 {
     System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
     pageSize = null;
     bf = null;
     extraEntries = null;
     List<DEngine> res = new List<DEngine>();
     // load zipfile
     using (ZipFile zf = new ZipFile(fileName))
     {
         // find pages ini file entry
         byte[] data = Read(zf, PAGES_INI);
         if (data != null)
         {
             // read general background figure
             byte[] genBkgndFigureData = Read(zf, GENBKGNDFIGURE);
             if (genBkgndFigureData != null)
             {
                 List<Figure> figs = FigureSerialize.FromXml(encoding.GetString(genBkgndFigureData));
                 if (figs.Count == 1 && figs[0] is BackgroundFigure)
                 {
                     LoadImage(zf, figs[0]);
                     bf = (BackgroundFigure)figs[0];
                     // read page size from background figure
                     if (bf.Width > 0 && bf.Height > 0)
                         pageSize = new DPoint(bf.Width, bf.Height);
                 }
             }
             // create Nini config source from pages ini entry stream
             IniConfigSource source = new IniConfigSource(new MemoryStream(data));
             // load each page info mentioned in ini entry
             foreach (IConfig config in source.Configs)
             {
                 // create new DEngine for page
                 DEngine de = new DEngine(undoRedoArea);
                 // set page size
                 if (config.Contains(PAGESIZE))
                     de.PageSize = DPoint.FromString(config.Get(PAGESIZE));
                 if (config.Contains(PAGENAME))
                     de.PageName = config.Get(PAGENAME);
                 // set the figures
                 if (config.Contains(FIGURELIST))
                 {
                     string figureListEntryName = config.Get(FIGURELIST);
                     data = Read(zf, figureListEntryName);
                     if (data != null)
                     {
                         List<Figure> figs = FigureSerialize.FromXml(encoding.GetString(data));
                         foreach (Figure f in figs)
                         {
                             de.AddFigure(f);
                             LoadImage(zf, f);
                         }
                     }
                 }
                 // set the background figure
                 if (config.Contains(BACKGROUNDFIGURE))
                 {
                     string backgroundFigureEntryName = config.Get(BACKGROUNDFIGURE);
                     data = Read(zf, backgroundFigureEntryName);
                     if (data != null)
                     {
                         List<Figure> figs = FigureSerialize.FromXml(encoding.GetString(data));
                         if (figs.Count == 1 && figs[0] is BackgroundFigure)
                         {
                             LoadImage(zf, figs[0]);
                             de.SetBackgroundFigure((BackgroundFigure)figs[0], true);
                         }
                     }
                 }
                 else if (bf != null)
                     de.SetBackgroundFigure(bf, false);
                 // add to list of DEngines
                 res.Add(de);
             }
             // read extra entries
             if (extraEntryDirs != null)
             {
                 extraEntries = new Dictionary<string, byte[]>();
                 foreach (string dir in extraEntryDirs)
                 {
                     IEnumerator en = zf.GetEnumerator();
                     en.Reset();
                     while (en.MoveNext())
                     {
                         ZipEntry entry = (ZipEntry)en.Current;
                         if (entry.Name.IndexOf(dir) == 0)
                             extraEntries.Add(entry.Name, Read(zf, entry.Name));
                     }
                 }
             }
         }
     }
     return res;
 }
开发者ID:djpnewton,项目名称:ddraw,代码行数:95,代码来源:FileHelper.cs

示例10: Extract

        /// <summary>
        /// Extracts the specified zip file stream.
        /// </summary>
        /// <param name="fileStream">The zip file stream.</param>
        /// <returns></returns>
        public bool Extract(Stream fileStream)
        {
            if (null == fileStream) return false;

            CleanFromTemp();

            NewTempPath();

            _isValid = true;

            ZipFile zipFile = null;

            try
            {
                zipFile = new ZipFile(fileStream);

                IEnumerator enumerator = zipFile.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    ZipEntry entry = (ZipEntry)enumerator.Current;

                    ExtractZipEntry(zipFile, entry);
                }
            }
            catch (Exception ex)
            {
                _isValid = false;
                _exceptionMessage = ex.Message;

                CleanFromTemp();
            }
            finally
            {
                fileStream.Close();

                if (null != zipFile) zipFile.Close();
            }

            return _isValid ? CheckFolderTree() : false;
        }
开发者ID:thaond,项目名称:vdms-sym-project,代码行数:46,代码来源:ZipWorker.cs

示例11: Extract

        /// <summary>
        /// Extracts the specified zip file stream.
        /// </summary>
        /// <param name="fileStream">The zip file stream.</param>
        /// <returns></returns>
        public bool Extract(Stream fileStream)
        {
            if (null == fileStream) return false;

            CleanFromTemp();

            NewTempPath();

            _isValid = true;

            ZipFile zipFile = null;

            try
            {
                zipFile = new ZipFile(fileStream);
                
                IEnumerator enumerator = zipFile.GetEnumerator();
                //System.Diagnostics.Debug.WriteLine(string.Format("Enumerating {0} zipfiles", zipFile.Count.ToString()));
                while (enumerator.MoveNext())
                {
                    ZipEntry entry = (ZipEntry)enumerator.Current;
                  //  System.Diagnostics.Debug.WriteLine(entry.ZipFileIndex.ToString() + " " + entry.Name);
                    
                    ExtractZipEntry(zipFile, entry);
                }
            }
            catch (Exception ex)
            {
                _isValid = false;
                _exceptionMessage = ex.Message;

                CleanFromTemp();
            }
            finally
            {
                fileStream.Close();

                if (null != zipFile) zipFile.Close();
            }

            return _isValid ? CheckFolderTree() : false;
        }
开发者ID:yuyi1,项目名称:Verdezyne-Operations,代码行数:47,代码来源:ZipWorker.cs

示例12: ZipEntryWrapperEnumerator

 public ZipEntryWrapperEnumerator(ZipFile file)
 {
   enumerator = file.GetEnumerator();
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:4,代码来源:ZippedStreamWrapper.cs

示例13: 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 method-filter to apply to files.</param>
        /// <param name="directoryFilter">A method-filter to apply to directories.</param>
        public void ExtractZip(
            string zipFileName,
            string targetDirectory,
            Overwrite overwrite,
            ConfirmOverwriteDelegate confirmDelegate,
            Func<string, bool> fileFilter,
            Func<string, bool> directoryFilter)
        {
            if ((overwrite == Overwrite.Prompt) && (confirmDelegate == null))
            {
                throw new ArgumentNullException("confirmDelegate");
            }

            continueRunning_ = true;
            overwrite_ = overwrite;
            confirmDelegate_ = confirmDelegate;
            extractNameTransform_ = new WindowsNameTransform(targetDirectory);

            restoreDateTimeOnExtract_ = true;

            Stream inputStream = File.Open(zipFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            using (zipFile_ = new ZipFile(inputStream))
            {

            #if !NETCF_1_0
                if (password_ != null)
                {
                    zipFile_.Password = password_;
                }
            #endif
                zipFile_.IsStreamOwner = true;
                System.Collections.IEnumerator enumerator = zipFile_.GetEnumerator();
                while (continueRunning_ && enumerator.MoveNext())
                {
                    ZipEntry entry = (ZipEntry)enumerator.Current;
                    if (entry.IsFile)
                    {
                        // TODO Path.GetDirectory can fail here on invalid characters.
                        if (directoryFilter(Path.GetDirectoryName(entry.Name)) && fileFilter(entry.Name))
                        {
                            ExtractEntry(entry);
                        }
                    }
                    else if (entry.IsDirectory)
                    {
                        if (directoryFilter(entry.Name) && CreateEmptyDirectories)
                        {
                            ExtractEntry(entry);
                        }
                    }
                }
            }
        }
开发者ID:depend86,项目名称:SharpZipLib,代码行数:62,代码来源:FastZip.cs

示例14: GetUnzipFileSize

        public static long GetUnzipFileSize(string strZipFile)
        {
            long lngUnzipFileSize = 0;

            try
            {
                ZipFile zf = new ZipFile(strZipFile);

                System.Collections.IEnumerator ie = zf.GetEnumerator();

                while (ie.MoveNext())
                {
                    ZipEntry ze = (ZipEntry)ie.Current;
                    lngUnzipFileSize += ze.Size;
                }

                zf.Close();

                return lngUnzipFileSize;
            }
            catch (Exception ex)
            {
                //LogClass.WriteLog("GetUnzipFileSize Exception: " + ex.Message);
                lngUnzipFileSize = 0;
                return lngUnzipFileSize;
            }
        }
开发者ID:priceLiu,项目名称:Enterprise.Company,代码行数:27,代码来源:ZipUtil.cs


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