Regarding your question: Try using this overload of the
CreateViewAccessor[
^]-Method and specify Read-Access there as well and please use a using-Block, like so:
using (var view1 = file1.CreateViewAccessor(0, file1.Length, MemoryMappedFileAccess.Read))
{
}
Also use a using-Block for MemoryMappedFile file1 = MemoryMappedFile.CreateFromFile ...
Regarding your overall intention: The last question you asked was about a OutOfMemoryException because you used the Levenshtein-Distance-Algorithm to compare PDF's. Now you're trying to compare them byte-by-byte. Two questions for you:
- Why you would need a MemoryMappedFile for this approach?
- What are you actually trying to achieve?