none
Using memory mapped files RRS feed

  • Question

  • Hi,

    I want to read a large file using memory mappedf file. Below is the code...

    long offset = 0x10000000; // 256 megabytes
            long length = 0x20000000; // 512 megabytes
    
            // Create the memory-mapped file.
            using (var mmf = MemoryMappedFile.CreateFromFile(textBox1.Text, FileMode.Open,"ImgA"))
            {
                // 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, MemoryMappedFileAccess.Read))
                {
                 //...................
    .................................
    ...........................
                }
            }
    


     But I get an exception while executing 'createviewaccesor'- System.UnauthorizedAccessException was unhandled
    Message=Access to the path is denied.

    The file is not read only file.This happens with any filein the machine. I tried by changing my 3rd argument of 'createviewaccesor with all available options in MemoryMappedFileAccess, still the issue occurs.

    Can anyone help me to fix this?
    Wednesday, March 27, 2013 10:02 AM

Answers

All replies