0

我有一种感觉,我做错了什么,但我不确定是什么。

这是我的代码:

        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”...

我想我误解了字节是如何工作的,但我不完全确定......

任何帮助深表感谢!

4

1 回答 1

1

在文本框中,您在第二个循环中用值 68 (0x44) 覆盖值 34 (0x22)。

您的程序按编程方式工作。内存映射文件的幸运逃脱。

于 2013-01-15T01:21:13.703 回答