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


C# BinaryWriter.WriteStructure方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:MadnessFreak,项目名称:IntegrityChecker,代码行数:31,代码来源:FileIntegrity.cs

示例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);
                }
            }
        }
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:19,代码来源:CVMDirectoryListing.cs

示例3: InternalWrite

 internal void InternalWrite(BinaryWriter writer)
 {
     writer.WriteStructure(_header);
 }
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:4,代码来源:CVMDirectoryListingEntry.cs

示例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());
            }
        }
开发者ID:Rex-Hays,项目名称:GNIDA,代码行数:21,代码来源:OffsetSizeCalculator.cs

示例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;
        }
开发者ID:Rex-Hays,项目名称:GNIDA,代码行数:30,代码来源:OffsetSizeCalculator.cs


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