Does the SafeBuffer.Read
method change the current position?
#86752
-
The Remarks section for the
However, When I prepared a test program to verify this, I did not observe any behavior that changes the current position. Could this be a documentation bug? using System.IO.MemoryMappedFiles;
File.WriteAllBytes("a.bin", new byte[]{0x1, 0x02, 0x03});
using(var mmf = System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile("a.bin"))
{
using (var accessor = mmf.CreateViewAccessor())
{
Console.WriteLine( $"{accessor.SafeMemoryMappedViewHandle.Read<byte>(0):X}"); // 1
Console.WriteLine( $"{accessor.SafeMemoryMappedViewHandle.Read<byte>(0):X}"); // 1
Console.WriteLine( $"{accessor.SafeMemoryMappedViewHandle.Read<byte>(0):X}"); // 1
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The documentation seems wrong. |
Beta Was this translation helpful? Give feedback.
The documentation seems wrong.
SafeBuffer
does not have a notion of "current position"; all its read/write methods take the offset as a parameter.