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


C# ZipInputStream.CloseEntry方法代码示例

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


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

示例1: UnpackData

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Unzip a byte array and return unpacked data
		/// </summary>
		/// <param name="data">Byte array containing data to be unzipped</param>
		/// <returns>unpacked data</returns>
		/// ------------------------------------------------------------------------------------
		public static byte[] UnpackData(byte[] data)
		{
			if (data == null)
				return null;
			try
			{
				MemoryStream memStream = new MemoryStream(data);
				ZipInputStream zipStream = new ZipInputStream(memStream);
				zipStream.GetNextEntry();
				MemoryStream streamWriter = new MemoryStream();
				int size = 2048;
				byte[] dat = new byte[2048];
				while (true)
				{
					size = zipStream.Read(dat, 0, dat.Length);
					if (size > 0)
					{
						streamWriter.Write(dat, 0, size);
					}
					else
					{
						break;
					}
				}
				streamWriter.Close();
				zipStream.CloseEntry();
开发者ID:sillsdev,项目名称:WorldPad,代码行数:33,代码来源:DataZip.cs

示例2: Deserialize

        /// <summary>
        /// This deserializes an adpack from a file.
        /// </summary>
        /// <param name="s">The stream to read from.</param>
        public void Deserialize(Stream s)
        {
            ZipInputStream zis = new ZipInputStream(s);
            ZipEntry entry;
            Metadata = new SortedList<string, string>();
            Files = new SortedList<string, AdPackEntry>();

            SortedList<String, byte[]> otherFiles = new SortedList<string, byte[]>();

            while ((entry = zis.GetNextEntry()) != null)
            {
                if (entry.IsCrypted)
                {
                    //MessageBox.Show("This adpack is encrypted, so it cannot be displayed.  Please do not encrypt adpack files.");
                    throw new Exception("Adpack is encrypted!");
                }
                switch (entry.Name.ToLowerInvariant())
                {
                    case "metadata.dat":
                        byte[] meta = new byte[entry.Size];
                        zis.Read(meta, 0, (int)entry.Size);
                        HandleMetadata(meta);
                        break;
                    case "filelist.dat":
                        byte[] fl = new byte[entry.Size];
                        zis.Read(fl, 0, (int)entry.Size);
                        HandleFileList(fl);
                        break;
                    default:
                        byte[] d = new byte[entry.Size];
                        zis.Read(d, 0, (int)entry.Size);
                        otherFiles[entry.Name] = d;
                        break;
                }

                zis.CloseEntry();
            }

            // check product id, because it's not just for bf2142
            if (Metadata["product"].ToLowerInvariant() != Common.AppInfos[AppID].AppNameShort)
            {
                String correctApp = "";
                if (Common.AppShortNames.ContainsKey(Metadata["product"].ToLowerInvariant())) {
                    correctApp = Common.AppInfos[Common.AppShortNames[Metadata["product"].ToLowerInvariant()]].AppName;
                } else {
                    correctApp = "Unsupported (" + Metadata["product"].ToLowerInvariant() + ")";
                }
                throw new Exception("Adpack is not for " + Common.AppInfos[AppID].AppName + ", it is for " + correctApp + ".");
            }

            // iterate through the other files
            foreach (KeyValuePair<String, byte[]> file in otherFiles)
            {
                if (Files.ContainsKey(file.Key))
                {
                    // referenced data.
                    Files[file.Key].SetDDSData(file.Value);
                }
            }

            List<String> RemovalList = new List<string>();
            foreach (KeyValuePair<String, AdPackEntry> file in Files)
            {
                // check each has data attached.
                if (file.Value.DDSData == null)
                {
                    //MessageBox.Show("Warning: Missing DDS image file '" + file.Key + "'.  The adpack file may be corrupt or encrypted.");
                    RemovalList.Add(file.Key);
                }
            }
            foreach (String item in RemovalList)
            {
                Files.Remove(item);
            }
        }
开发者ID:micolous,项目名称:igaeditor,代码行数:79,代码来源:AdPack.cs


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