UnauthorizedAccessException on MemoryMappedFile in C# 4

后端 未结 4 1874
醉梦人生
醉梦人生 2021-01-11 12:20

I wanted to play around with using a MemoryMappedFile to access an existing binary file. If this even at all possible or am I a crazy person?

The idea would be to ma

4条回答
  •  攒了一身酷
    2021-01-11 12:31

    If the size is more than the file length, it gives the UnAuthorized Access exception. Because we are trying to access memory beyond the limits of the file.

    var view = mmf.CreateViewAccessor(offset, size, MemoryMappedFileAccess.Read);
    

提交回复
热议问题