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


C# ZipFile.Count方法代码示例

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


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

示例1: dump

        private void dump(string filename)
        {
            if (Directory.Exists(filename + "_d"))
                Directory.Delete(filename + "_d", true);

            Directory.CreateDirectory(filename + "_d");

            ShuffleARC_M Archive = new ShuffleARC_M(filename);
            using (var fs = File.OpenRead(filename))
            {
                for (int i = 0; i < Archive.Files.Count(); i++)
                {
                    byte[] ZipBuffer = new byte[Archive.Files[i].Length];
                    fs.Seek(Archive.Files[i].Offset, SeekOrigin.Begin);
                    fs.Read(ZipBuffer, 0, ZipBuffer.Length);

                    string ZipName = Archive.Files[i].NameHash.ToString("X8") + ".zip";
                    string outlet = Path.Combine(filename + "_d", ZipName);
                    File.WriteAllBytes(outlet, ZipBuffer);

                    string file = "";
                    try
                    {
                        using (ZipFile Zip = new ZipFile(outlet))
                        {
                            if (Zip.Count() == 1)
                            {
                                file = Zip[0].FileName.Trim('\0');
                                if (file == "") Zip[0].FileName = file = i.ToString("0000");
                                Zip.Save();
                            }
                            Zip.ExtractAll(filename + "_d");
                        }
                        // Decrypt File
                        File.Delete(outlet);

                        file = Path.Combine(filename + "_d", file);
                        if ((Archive.Files[i].F2 & 0x200) > 0)
                        {
                            byte[] data = File.ReadAllBytes(file);
                            XOR(data);
                            File.WriteAllBytes(file, data);
                        }
                    }
                    catch
                    {
                        file = i.ToString("0000");
                    }

                    // Check for PVR
                    try
                    {
                        byte[] z = File.ReadAllBytes(file);
                        int off = BitConverter.ToInt32(z, 0x4);
                        int val = (BitConverter.ToInt32(z, 0x2C + off) & 0xFFFFFF);
                        if (val == 0x525650)
                        {
                            File.WriteAllBytes(Path.Combine("pvr", Archive.Files[i].NameHash + "_" + i.ToString("0000") + ".pvr"), z.Skip(off).ToArray());
                            File.Delete(file);
                            continue;
                        }
                    } catch {}
                    // Check for GHVK pack
                    try
                    {
                        byte[] z = File.ReadAllBytes(file);
                        if ((BitConverter.ToUInt32(z, 0)) == 0x4B564847)
                        {
                            int count = BitConverter.ToInt16(z, 8);
                            // int o1 = BitConverter.ToInt32(z, 0x40);
                            int o2 = BitConverter.ToInt32(z, 0x44);
                            // int o3 = BitConverter.ToInt32(z, 0x48);
                            int o4 = BitConverter.ToInt32(z, 0x4C);
                            int o5 = BitConverter.ToInt32(z, 0x50);

                            string[] filenames = new string[count];
                            byte[][] files = new byte[count][];

                            for (int f = 0; f < count; f++)
                            {
                                int startstr = BitConverter.ToInt32(z, o4 + f*4);
                                int offset = BitConverter.ToInt32(z, o5 + f*4);
                                int length = BitConverter.ToInt32(z, o2 + f*4);
                                filenames[f] = Encoding.ASCII.GetString(z.Skip(startstr).TakeWhile(b => !b.Equals(0)).ToArray());
                                files[f] = z.Skip(offset).Take(length).ToArray();

                                string outFile = Path.Combine("pkm2", Archive.Files[i].NameHash.ToString("X8"), filenames[f]);
                                new FileInfo(outFile).Directory.Create();

                                File.WriteAllBytes(outFile, files[f]);
                            }

                            File.Delete(file);
                            continue;
                        }

                    }
                    catch {}
                }
            }
//.........这里部分代码省略.........
开发者ID:kwsch,项目名称:shuffleMobile,代码行数:101,代码来源:Form1.cs


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