示例#1
1
        public static void TestFileStream()
        {
            using (FileStream stream = new FileStream("D:\\Test\\level.dat", FileMode.Create))
            {
                TagCompound root = MakeRootTag();

                NbtIO.WriteToStream(stream, root);

                Console.WriteLine("Input NBT:");
                Console.WriteLine(root.ToTreeString());

                Console.WriteLine("\nSaved {0} bytes.", stream.Length);
                Console.WriteLine();
            }

            using (FileStream stream = new FileStream("D:\\Test\\level.dat", FileMode.Open))
            {
                TagCompound parsed = NbtIO.Parse(stream);

                Console.WriteLine("Read NBT:");
                Console.WriteLine(parsed.ToTreeString());
            }
        }