本文整理汇总了C#中System.IO.BinaryWriter.WriteStructure方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteStructure方法的具体用法?C# BinaryWriter.WriteStructure怎么用?C# BinaryWriter.WriteStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteStructure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
// Methods
/// <summary>
/// Creates a new file integrity.
/// </summary>
/// <param name="path">The specified path.</param>
public void Create(string path)
{
var header = new FileIntegrityHeader()
{
Tag = FileIntegrity.FileTag,
Version = FileIntegrity.FileVersion
};
Scan(Environment.CurrentDirectory);
header.EntryCount = EntryCount;
using (var writer = new BinaryWriter(File.Open(FileIntegrity.FileName, FileMode.Create, FileAccess.Write)))
{
writer.WriteStructure<FileIntegrityHeader>(header);
foreach (var entry in Entries)
{
writer.Write(entry.FileNameLen);
writer.Write(entry.FileName.ToCharArray(), 0, entry.FileNameLen);
writer.Write(entry.LastModifiedTime);
writer.Write(entry.Size);
writer.Write(entry.Checksum);
}
}
}
示例2: InternalWrite
internal void InternalWrite(BinaryWriter writer)
{
writer.WriteStructure(_header);
for (int i = 0; i < _header.entryCount; i++)
{
_subEntries[i].InternalWrite(writer);
}
writer.AlignPosition(16);
for (int i = 0; i < _header.entryCount; i++)
{
if (i > 1 && _subEntries[i].Flags.HasFlagUnchecked(RecordFlags.DirectoryRecord))
{
_subEntries[i].DirectoryListing.InternalWrite(writer);
}
}
}
示例3: InternalWrite
internal void InternalWrite(BinaryWriter writer)
{
writer.WriteStructure(_header);
}
示例4: WriteMetaData
private void WriteMetaData(Workspace workspace, BinaryWriter sectionWriter)
{
// write metadata header
sectionWriter.WriteStructure(workspace.NewNetHeader.MetaDataHeader._reader.metadataHeader1);
sectionWriter.Write(Encoding.ASCII.GetBytes(workspace.NewNetHeader.MetaDataHeader.VersionString));
sectionWriter.WriteStructure(workspace.NewNetHeader.MetaDataHeader._reader.metadataHeader2);
// write metadata stream headers
foreach (MetaDataStream stream in workspace.NewNetHeader.MetaDataStreams)
{
sectionWriter.WriteStructure(stream._streamHeader);
sectionWriter.Write(Encoding.ASCII.GetBytes(stream.Name));
sectionWriter.Write(new byte[Align(stream.Name.Length + 1, 4)]);
}
// write metadata streams
foreach (MetaDataStream stream in workspace.NewNetHeader.MetaDataStreams)
{
sectionWriter.Write(stream._mainStream.ToArray());
}
}
示例5: CreateTextSection
private Section CreateTextSection(Workspace workspace)
{
Section section;
using (MemoryStream sectionStream = new MemoryStream())
{
using (BinaryWriter sectionWriter = new BinaryWriter(sectionStream))
{
// write import address dir space.
sectionWriter.Write(new byte[8]);
// write .net header
sectionWriter.WriteStructure(workspace.NewNetHeader._rawHeader);
// write method bodies
sectionWriter.Write(workspace.MethodBodyTable.Stream.ToArray());
// write resources dir
sectionWriter.Write(Constructor.OriginalAssembly.NETHeader.ResourcesDirectory.GetBytes());
// write metadata
WriteMetaData(workspace, sectionWriter);
// write import dir
}
section = new Section(".text", 0, sectionStream.ToArray());
}
return section;
}