當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。