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


C# Zip.ZipEntry类代码示例

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


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


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