示例#1
0
        public static void TreeToBinary(String TreePath, String BinaryPath)
        {
            var xs = new XmlSerializer(true);
            var x  = TreeFile.ReadFile(TreePath);
            var o  = xs.Read <World.World>(x);

            Byte[] b;
            using (var s = new World.BinaryWithoutFirefly.ByteArrayStream())
            {
                World.BinaryWithoutFirefly.BinaryTranslator.WorldToBinary(s, o);
                s.Position = 0;
                b          = s.ReadBytes(s.Length);
            }
            using (var s = Streams.CreateWritable(BinaryPath))
            {
                s.Write(b);
            }
        }
示例#2
0
        public static void BinaryToTree(String BinaryPath, String TreePath)
        {
            Byte[] b;
            using (var s = Streams.OpenReadable(BinaryPath))
            {
                b = s.Read((int)(s.Length));
            }
            World.World o;
            using (var s = new World.BinaryWithoutFirefly.ByteArrayStream())
            {
                s.WriteBytes(b);
                s.Position = 0;
                o          = World.BinaryWithoutFirefly.BinaryTranslator.WorldFromBinary(s);
            }
            var xs = new XmlSerializer(true);
            var x  = xs.Write <World.World>(o);

            TreeFile.WriteFile(TreePath, x);
        }