[英]Why isn't this memory-mapped file read correctly?
我感觉自己做错了什么,但不确定。
这是我的代码:
long offset = 0x009694E3;
long length = 0x02;
byte[] bytes = new byte[length];
// Create the memory-mapped file.
using (var mmf =
MemoryMappedFile.CreateFromFile(strFileName, FileMode.Open, "ISO"))
{
// Create a random access view, from the 256th megabyte (the offset)
// to the 768th megabyte (the offset plus length).
using (var accessor = mmf.CreateViewAccessor(offset, length))
{
// Make changes to the view.
for (long i = 0; i < length; i++)
{
bytes[i] = accessor.ReadByte(i);
dialogEdit.Text = bytes[i].ToString();
}
}
}
当我加载文件时,上述偏移处的文本为0x22 0x44(“ ASCII中的D”),但文本框的输出为“ 68” ...
我想我误解了字节的工作原理,但我不确定...
任何帮助深表感谢!
在文本框中,在第二个循环中将值34(0x22)替换为值68(0x44)。
您的程序按编程方式工作。 内存映射文件的幸运转义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.