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


C# EndianBinaryWriter.Close方法代码示例

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


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

示例1: Write

 public byte[] Write()
 {
     MemoryStream m = new MemoryStream();
     EndianBinaryWriter er = new EndianBinaryWriter(m, Endianness.LittleEndian);
     er.Write(StaticData, 0, StaticData.Length);
     _start_ModuleParams.AutoLoadStart = (uint)er.BaseStream.Position + RamAddress;
     foreach (var v in AutoLoadList) er.Write(v.Data, 0, v.Data.Length);
     _start_ModuleParams.AutoLoadListOffset = (uint)er.BaseStream.Position + RamAddress;
     foreach (var v in AutoLoadList) v.Write(er);
     _start_ModuleParams.AutoLoadListEnd = (uint)er.BaseStream.Position + RamAddress;
     long curpos = er.BaseStream.Position;
     er.BaseStream.Position = _start_ModuleParamsOffset;
     _start_ModuleParams.Write(er);
     er.BaseStream.Position = curpos;
     byte[] data = m.ToArray();
     er.Close();
     return data;
 }
开发者ID:LoveLeAnon,项目名称:EveryFileExplorer,代码行数:18,代码来源:ARM9.cs

示例2: Pack

        static void Pack(string Folder, EndianBinary.Endian Endian)
        {
            int FileCount = Directory.GetFiles(Folder).Length;

            int RealCount = 0;
            for (int i = 0; i < FileCount; i++)
            {
                string FileName = Path.Combine(Folder, "file_" + i.ToString() + ".lang");
                if (!File.Exists(FileName)) FileName = Path.GetFileNameWithoutExtension(FileName) + ".bin";
                if (File.Exists(FileName)) RealCount++;
            }

            FileStream Output = new FileStream(Folder + ".lnk", FileMode.Create);
            EndianBinaryWriter Writer = new EndianBinaryWriter(Output, Endian);
            Writer.Write(Encoding.ASCII.GetBytes("MSSG"));
            Writer.Write((uint)0);
            Writer.Write((ulong)RealCount);

            long TableOffset = 0x20;
            long DataOffset = TableOffset + RealCount * 0x20;
            while ((DataOffset & 0x7ff) != 0) DataOffset++;

            for (int i = 0; i < FileCount; i++)
            {
                string FileName = Path.Combine(Folder, "file_" + i.ToString() + ".lang");
                if (!File.Exists(FileName)) FileName = Path.GetFileNameWithoutExtension(FileName) + ".bin";

                if (File.Exists(FileName))
                {
                    byte[] Buffer = File.ReadAllBytes(FileName);

                    Writer.Seek(TableOffset, SeekOrigin.Begin);
                    Writer.Write((ulong)DataOffset);
                    Writer.Write((ulong)Buffer.Length);
                    Writer.Write((ulong)Buffer.Length);
                    TableOffset += 0x20;

                    Writer.Seek(DataOffset, SeekOrigin.Begin);
                    Writer.Write(Buffer);
                    while ((Output.Position & 0x7ff) != 0) Output.WriteByte(0);
                    DataOffset = Output.Position;
                }
            }

            Writer.Seek(0x10, SeekOrigin.Begin);
            Writer.Write((ulong)Output.Length);
            Writer.Write((ulong)0x800); //???

            Writer.Close();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Packed all files from \"" + Path.GetFileName(Folder) + "\"!");
            Console.ResetColor();
        }
开发者ID:gdkchan,项目名称:DOA5Tool,代码行数:54,代码来源:Program.cs


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