System.IO.File.ReadAllBytes for file larger than 2GB

后端 未结 1 773
你的背包
你的背包 2021-01-15 15:14

I have a large file that I need to copy to memory for further processing. The software works fine for files smaller than 2GB, but as soon as they pass this limit I get an ex

相关标签:
1条回答
  • 2021-01-15 15:36

    I doubt you can do anything faster than a memory mapped file http://msdn.microsoft.com/en-us/library/system.io.memorymappedfiles.memorymappedfile(v=vs.110).aspx.

    using ( var file = MemoryMappedFile.CreateFromFile( "F:\\VeryLargeFile.data" ) )
    {
    }
    

    You can then use CreateViewAccessor or CreateViewStream to manipulate the data.

    0 讨论(0)
提交回复
热议问题