本文整理汇总了C#中System.IO.FileStream.Read4ByteInt方法的典型用法代码示例。如果您正苦于以下问题:C# FileStream.Read4ByteInt方法的具体用法?C# FileStream.Read4ByteInt怎么用?C# FileStream.Read4ByteInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileStream
的用法示例。
在下文中一共展示了FileStream.Read4ByteInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseSegment
/// <summary>
/// Perform segment-specific processing on the raw data. At this point the four byte type has already been read
/// in, so the position is at the four byte length int.
/// </summary>
/// <param name="file">The city file that is being read in.</param>
internal virtual void ParseSegment(FileStream file)
{
Length = file.Read4ByteInt();
RawDataFileOffset = (int)file.Position;
Data = new byte[Length];
file.Read(Data, 0, Length);
}
示例2: ParseHeader
/// <summary>
/// Read in and validate the header of a city file.
/// </summary>
/// <param name="stream">File stream waiting at the header for instructions.</param>
/// <returns>The length (in bytes) of the data portion of this file.</returns>
private static int ParseHeader(FileStream reader)
{
// Case for too small of a file
if (reader.Length < 12)
throw new Exception("Unexpected file length.");
// Read 12-byte header.
string headChunk = reader.ReadString();
int dataLength = reader.Read4ByteInt();
string fileType = reader.ReadString();
// Make sure the header represents a valid city file.
if (!headChunk.Equals(HEADERCHUNK) || !fileType.Equals(FILETYPE))
throw new Exception("Invalid SC2000 file or corrupted header.");
return dataLength;
}