Exemplo n.º 1
0
        // 解析WZ文件
        public void ParseWzFile()
        {
            WzTools.CreateWzKey(WzMapleVersion.GMS);
            // 将内存中的数据初始化为一个二进制流准备读取
            BinaryReader reader = new BinaryReader(new MemoryStream(this.wzFileBytes));

            while (reader.PeekChar() != -1)
            {
                int    num             = reader.ReadInt32(); // 读取4个字节 05 00 00 00
                char[] stringToDecrypt = new char[num];
                for (int i = 0; i < num; i++)
                {
                    stringToDecrypt[i] = (char)((ushort)reader.ReadInt16());   // 读取2个字节 05 00
                }
                reader.ReadUInt16();
                string item = WzTools.DecryptString(stringToDecrypt);
                if ((reader.PeekChar() == -1) && (item[item.Length - 1] == '/'))
                {
                    item = item.TrimEnd("/".ToCharArray()) + "g";
                }
                this.listEntries.Add(item);
            }
            reader.Close();
        }