本文整理汇总了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;
}
示例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();
}