How to write super-fast file-streaming code in C#?

后端 未结 9 1912
遥遥无期
遥遥无期 2020-11-28 19:11

I have to split a huge file into many smaller files. Each of the destination files is defined by an offset and length as the number of bytes. I\'m using the following code:<

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 20:01

    (For future reference.)

    Quite possibly the fastest way to do this would be to use memory mapped files (so primarily copying memory, and the OS handling the file reads/writes via its paging/memory management).

    Memory Mapped files are supported in managed code in .NET 4.0.

    But as noted, you need to profile, and expect to switch to native code for maximum performance.

提交回复
热议问题