• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Zip.ZipEntry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Ionic.Zip.ZipEntry的典型用法代码示例。如果您正苦于以下问题:C# ZipEntry类的具体用法?C# ZipEntry怎么用?C# ZipEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ZipEntry类属于Ionic.Zip命名空间,在下文中一共展示了ZipEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AreEqual

 private bool AreEqual(ZipEntry approvedEntry, ZipEntry receivedEntry)
 {
     if (approvedEntry.IsDirectory && receivedEntry.IsDirectory)
     {
         return true;
     }
     using (var approvedStream = new MemoryStream())
     {
         using (var receivedStream = new MemoryStream())
         {
             approvedEntry.Extract(approvedStream);
             receivedEntry.Extract(receivedStream);
             var approvedBytes = approvedStream.ToArray();
             var receivedBytes = receivedStream.ToArray();
             var areEqual = approvedBytes == receivedBytes;
             for (int i = 0; i < receivedBytes.Length && i < approvedBytes.Length; i++)
             {
                 if (receivedBytes[i] != approvedBytes[i])
                 {
                     Logger.Event("Failed on {0}[{1}]      '{2}' != '{3}'", receivedEntry.FileName, i,
                         (char) receivedBytes[i], (char) approvedBytes[i]);
                     return false;
                 }
             }
             return true;
         }
     }
 }
开发者ID:approvals,项目名称:Approvals.Net.Excel,代码行数:28,代码来源:ZipApprover.cs


示例2: Handle

        protected override OperationResult Handle(ZipEntry entry, ZipFile zip)
        {
            string orig = entry.FileName;
            string stripped = GetStripped(entry.FileName);
            if (stripped == null)
            {
                if (entry.IsDirectory)
                {
                    zip.RemoveEntry(entry);
                    return OperationResult.Removed;
                }

                stripped = orig;
            }

            try
            {
                entry.FileName = stripped;
                return OperationResult.Changed;
            }
            catch (Exception ex)
            {
                string type = entry.IsDirectory ? "directory" : "file";
                throw new Exception(string.Format("Could not rename {0} '{1}' to '{2}'", type, orig, stripped), ex);
            }
        }
开发者ID:tgmayfield,项目名称:zip-dir-strip,代码行数:26,代码来源:DirStripOperation.cs


示例3: ZipPackagePart

 internal ZipPackagePart(ZipPackage package, ZipEntry entry)
 {
     Package = package;
     Entry = entry;
     SaveHandler = null;
     Uri = new Uri(package.GetUriKey(entry.FileName), UriKind.Relative);
 }
开发者ID:kidaa,项目名称:DissDlcToolkit,代码行数:7,代码来源:ZipPackagePart.cs


示例4: GetEntryMemoryStream

        public MemoryStream GetEntryMemoryStream(ZipEntry zipEntry)
        {
            var stream = new MemoryStream();
            zipEntry.Extract(stream);
            stream.Position = 0;

            return stream;
        }
开发者ID:cashwu,项目名称:testZip,代码行数:8,代码来源:ZipService.cs


示例5: LoadBitmap

 private static Bitmap LoadBitmap(ZipEntry zipEntry)
 {
     MemoryStream stream = new MemoryStream();
     zipEntry.Extract(stream);
     stream.Position = 0;
     Bitmap result = new Bitmap(stream);
     stream.Dispose();
     return result;
 }
开发者ID:CodesInChaos,项目名称:Go-Audio-Lesson-Tool,代码行数:9,代码来源:BoardSkin.cs


示例6: EmlParser

 /// <summary>
 /// Constructors
 /// </summary>
 /// <param name="ze"></param>
 public EmlParser(ZipEntry ze)
 {
     try
     {
         parseEML(ze);
     }
     catch (Exception ex)
     { throw ex; }
 }
开发者ID:DaHao,项目名称:RSPdf,代码行数:13,代码来源:EmlParser.cs


示例7: Create

        public static PartWrapper Create(ZipEntry part)
        {
            if (part.IsZip())
            {
                return new ZipPartWrapper(part);
            }

            return new PartWrapper(part);
        }
开发者ID:McDonaldConsulting,项目名称:VsixNugetifier,代码行数:9,代码来源:PartWrapper.cs


示例8: SetZipFile

		private static void SetZipFile(ZipEntry zipEntry, ZipFileInfo file)
		{
			if (!string.IsNullOrEmpty(file.Password))
				zipEntry.Password = file.Password;

			zipEntry.Comment = file.Comment;
			zipEntry.CompressionMethod = (Ionic.Zip.CompressionMethod)((int)file.CompressionMethod);
			zipEntry.CompressionLevel = (Ionic.Zlib.CompressionLevel)((int)file.CompressionLevel);
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:9,代码来源:CompressManager.Compress.cs


示例9: Check

		public void Check()
		{
			// Is there a valid input stream
			if (_stream == null)
				throw new FileNotFoundException("No valid file");

			// Now read gwz file and save for later use
			_zip = ZipFile.Read(_stream);

			if (_zip == null)
				throw new FileLoadException("No valid gwz file");

			foreach(ZipEntry zipEntry in _zip.Entries)
			{
				switch(Path.GetExtension(zipEntry.FileName).ToLower())
				{
					case ".lua":
						_luaFile = zipEntry;
						_luaFiles += 1;
						break;
				}
			}

			// Is there a Lua file?
			if (_luaFile == null)
				throw new FileNotFoundException("No valid Lua file found");

			// Is there more than one Lua file
			if (_luaFiles > 1)
				throw new FileLoadException("More than one Lua file found");

			// Any compilation errors of the Lua file
			LUA.Check(_zip[_luaFile.FileName].OpenReader(), _luaFile.FileName);

			// Extract cartridge data from Lua file
			cartridge = LUA.Extract(_zip[_luaFile.FileName].OpenReader());

			// Save Lua file name for later use
			cartridge.LuaFileName = _luaFile.FileName;

			// Now check, if all media resources files exist
			foreach(Media media in cartridge.Medias) {
				foreach(MediaResource resource in media.Resources) {
					// Check, if filename is in list of files
					if (!_zip.EntryFileNames.Contains(resource.Filename))
					{
						if (string.IsNullOrWhiteSpace(resource.Filename))
							throw new FileNotFoundException("The Lua file is referencing a file without a filename");
						else
							throw new FileNotFoundException(String.Format("The GWZ is missing a file referred to by the cartridge's code. The file name is: {0}", resource.Filename));
					}
				}
			}

			// Now all is checked without any problems
			// So it seams, that this GWZ file is valid
		}
开发者ID:WFoundation,项目名称:WF.Compiler,代码行数:57,代码来源:GWZ.cs


示例10: Handle

        protected override OperationResult Handle(ZipEntry entry, ZipFile zip)
        {
            if (entry.IsDirectory && (entry.Attributes & FileAttributes.Directory) != FileAttributes.Directory)
            {
                entry.Attributes |= FileAttributes.Directory;
            }

            // This just helps if a file is resaved. It shouldn't be treated as modified if this cleans something up.
            return OperationResult.NoChange;
        }
开发者ID:tgmayfield,项目名称:zip-dir-strip,代码行数:10,代码来源:CleanDirectoryAttributesOperation.cs


示例11: Handle

        protected override OperationResult Handle(ZipEntry entry, ZipFile zip)
        {
            if (_regex.IsMatch(entry.FileName))
            {
                zip.RemoveEntry(entry);
                return OperationResult.Removed;
            }

            return OperationResult.NoChange;
        }
开发者ID:tgmayfield,项目名称:zip-dir-strip,代码行数:10,代码来源:RemoveOperation.cs


示例12: ContentSection

 public ContentSection(ZipEntry entry)
 {
     Id = Path.GetFileNameWithoutExtension(entry.FileName);
     ArchivePath = entry.FileName;
     using (Stream s = entry.OpenReader())
     {
         using (StreamReader sr = new StreamReader(s))
         {
             Content = sr.ReadToEnd();
         }
     }
 }
开发者ID:sashaMilka,项目名称:MultiReader,代码行数:12,代码来源:ContentSection.cs


示例13: ExtractFileToStream

 public static MemoryStream ExtractFileToStream(string zipSource, string filePath)
 {
     MemoryStream stream = new MemoryStream();
     using (ZipFile zip = ZipFile.Read(zipSource))
     {
         var matchFile = new ZipEntry();
         foreach (var file in zip.Where(file => file.FileName == filePath))
             matchFile = file;
         matchFile.Extract(stream);
     }
     return stream;
 }
开发者ID:DarthWeirdo,项目名称:PLINQ_load_balancing_tutorial,代码行数:12,代码来源:UnZipper.cs


示例14: ExtractFileFromStream

        public static string ExtractFileFromStream(ZipEntry entry)
        {
            var reader = new MemoryStream();
            entry.Extract(reader);
            reader = new MemoryStream(reader.ToArray());

            var streamReader = new StreamReader(reader);

            var text = streamReader.ReadToEnd();
            reader.Dispose();
            return text;
        }
开发者ID:BorisPenev,项目名称:OpenJudgeSystem,代码行数:12,代码来源:ZippedTestsParser.cs


示例15: ForRead

        public static ZipCrypto ForRead(string password, ZipEntry e)
        {
            System.IO.Stream s = e._archiveStream;
            e._WeakEncryptionHeader = new byte[12];
            byte[] eh = e._WeakEncryptionHeader;
            ZipCrypto z = new ZipCrypto();

            if (password == null)
                throw new BadPasswordException("This entry requires a password.");

            z.InitCipher(password);

            ZipEntry.ReadWeakEncryptionHeader(s, eh);

            // Decrypt the header.  This has a side effect of "further initializing the
            // encryption keys" in the traditional zip encryption. 
            byte[] DecryptedHeader = z.DecryptMessage(eh, eh.Length);

            // CRC check
            // According to the pkzip spec, the final byte in the decrypted header 
            // is the highest-order byte in the CRC. We check it here. 
            if (DecryptedHeader[11] != (byte)((e._Crc32 >> 24) & 0xff))
            {
                // In the case that bit 3 of the general purpose bit flag is set to
                // indicate the presence of an 'Extended File Header' or a 'data
                // descriptor' (signature 0x08074b50), the last byte of the decrypted
                // header is sometimes compared with the high-order byte of the
                // lastmodified time, rather than the high-order byte of the CRC, to
                // verify the password.
                //
                // This is not documented in the PKWare Appnote.txt.  
                // This was discovered this by analysis of the Crypt.c source file in the InfoZip library
                // http://www.info-zip.org/pub/infozip/

                if ((e._BitField & 0x0008) != 0x0008)
                {
                    throw new BadPasswordException("The password did not match.");
                }
                else if (DecryptedHeader[11] != (byte)((e._TimeBlob >> 8) & 0xff))
                {
                    throw new BadPasswordException("The password did not match.");
                }

                // We have a good password. 
            }
            else
            {
                // A-OK
            }
            return z;
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:51,代码来源:ZipCrypto.cs


示例16: GenerateBitmapFromZipEntry

        private BitmapSource GenerateBitmapFromZipEntry(ZipEntry entry)
        {
            MemoryStream stream = new MemoryStream();
            entry.Extract(stream);
            stream.Seek(0, SeekOrigin.Begin);

            var decoder = BitmapDecoder.Create(stream,
                BitmapCreateOptions.None,
                BitmapCacheOption.OnLoad);
            BitmapSource bitmapSource = decoder.Frames[0];

            stream.Dispose();

            return bitmapSource;
        }
开发者ID:xp880906,项目名称:MangaViewer,代码行数:15,代码来源:MainWindowViewModel.cs


示例17: ReadEntry

        /// <summary>
        /// Reads one <c>ZipEntry</c> from the given stream.  If the entry is encrypted, we don't
        /// decrypt at this point.  We also do not decompress.  Mostly we read metadata.
        /// </summary>
        /// <param name="zc">the ZipContainer this entry belongs to.</param>
        /// <param name="first">true of this is the first entry being read from the stream.</param>
        /// <returns>the <c>ZipEntry</c> read from the stream.</returns>
        internal static ZipEntry ReadEntry(ZipContainer zc, bool first)
        {
            ZipFile zf = zc.ZipFile;

            Stream s = zc.ReadStream;

            System.Text.Encoding defaultEncoding = zc.ProvisionalAlternateEncoding;
            ZipEntry entry = new ZipEntry();
            entry._Source = ZipEntrySource.ZipFile;
            entry._container = zc;
            entry._archiveStream = s;
            if (zf != null)
                zf.OnReadEntry(true, null);

            if (first) HandlePK00Prefix(s);

            // Read entry header, including any encryption header
            if (!ReadHeader(entry, defaultEncoding)) return null;

            // Store the position in the stream for this entry
            // change for workitem 8098
            entry.__FileDataPosition = entry.ArchiveStream.Position;

            // seek past the data without reading it. We will read on Extract()
            s.Seek(entry._CompressedFileDataSize + entry._LengthOfTrailer, SeekOrigin.Current);
            // workitem 10178
            Ionic.Zip.SharedUtilities.Workaround_Ladybug318918(s);

            // ReadHeader moves the file pointer to the end of the entry header,
            // as well as any encryption header.

            // CompressedFileDataSize includes:
            //   the maybe compressed, maybe encrypted file data
            //   the encryption trailer, if any
            //   the bit 3 descriptor, if any

            // workitem 5306
            // http://www.codeplex.com/DotNetZip/WorkItem/View.aspx?WorkItemId=5306
            HandleUnexpectedDataDescriptor(entry);

            if (zf != null)
            {
                zf.OnReadBytes(entry);
                zf.OnReadEntry(false, entry);
            }

            return entry;
        }
开发者ID:pilehave,项目名称:headweb-mp,代码行数:55,代码来源:ZipEntry.Read.cs


示例18: GetStringFile

        public static string GetStringFile(ZipEntry zipEntry)
        {
            if (zipEntry != null)
            {
                using (var stream = zipEntry.OpenReader())
                {
                    using (StreamReader sr = new StreamReader(stream, KPGenericUtil.GetDefaultEncoding()))
                    {
                        string fileString = sr.ReadToEnd();
                        return fileString;
                    }
                }
            }

            return String.Empty;
        }
开发者ID:NumericTechnology,项目名称:Platanum.Net,代码行数:16,代码来源:ZipUtil.cs


示例19: Save

        private static void Save(ZipEntry entry, string outputFilePath)
        {
            using (var input = entry.OpenReader())
            {
                var folderPath = Path.GetDirectoryName(outputFilePath);
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }

                using (Stream output = File.OpenWrite(outputFilePath))
                {
                    CopyStream(input, output);
                }
            }
        }
开发者ID:SaintSkeeta,项目名称:Sitecore-Nuget-Package-Discoverer,代码行数:16,代码来源:Program.cs


示例20: CopyMetaData

 /// <summary>
 /// Copy metadata that may have been changed by the app.  We do this when
 /// resetting the zipFile instance.  If the app calls Save() on a ZipFile, then
 /// tries to party on that file some more, we may need to Reset() it , which
 /// means re-reading the entries and then copying the metadata.  I think.
 /// </summary>
 internal void CopyMetaData(ZipEntry source)
 {
     this.__FileDataPosition = source.__FileDataPosition;
     this.CompressionMethod = source.CompressionMethod;
     this._CompressionMethod_FromZipFile = source._CompressionMethod_FromZipFile;
     this._CompressedFileDataSize = source._CompressedFileDataSize;
     this._UncompressedSize = source._UncompressedSize;
     this._BitField = source._BitField;
     this._Source = source._Source;
     this._LastModified = source._LastModified;
     this._Mtime = source._Mtime;
     this._Atime = source._Atime;
     this._Ctime = source._Ctime;
     this._ntfsTimesAreSet = source._ntfsTimesAreSet;
     this._emitUnixTimes = source._emitUnixTimes;
     this._emitNtfsTimes = source._emitNtfsTimes;
 }
开发者ID:pilehave,项目名称:headweb-mp,代码行数:23,代码来源:ZipEntry.Write.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Zip.ZipFile类代码示例发布时间:2022-05-26
下一篇:
C# Lang.IokeObject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap