我有以下来源:如何知道C#中BinaryReader的当前偏移量?
public static void DisplayValues()
{
float aspectRatio;
string tempDirectory;
int autoSaveTime;
bool showStatusBar;
if (File.Exists(fileName))
{
using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
{
aspectRatio = reader.ReadSingle();
tempDirectory = reader.ReadString();
------------------------------------------------> I want to know current offset.
autoSaveTime = reader.ReadInt32();
showStatusBar = reader.ReadBoolean();
}
Console.WriteLine("Aspect ratio set to: " + aspectRatio);
Console.WriteLine("Temp directory is: " + tempDirectory);
Console.WriteLine("Auto save time set to: " + autoSaveTime);
Console.WriteLine("Show status bar: " + showStatusBar);
}
}
我必须找出当前BinaryReader在偏移。
得到的位置不要注意,您做出强烈的假设,即BinaryReader在不从基础缓冲区的字节流。它会缓冲字节。但不是以一种会以字节为单位的方式。 –