Reading large text files with streams in C#

后端 未结 11 1855
野的像风
野的像风 2020-11-22 08:28

I\'ve got the lovely task of working out how to handle large files being loaded into our application\'s script editor (it\'s like VBA for our internal product for quick macr

11条回答
  •  不知归路
    2020-11-22 08:59

    For binary files, the fastest way of reading them I have found is this.

     MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(file);
     MemoryMappedViewStream mms = mmf.CreateViewStream();
     using (BinaryReader b = new BinaryReader(mms))
     {
     }
    

    In my tests it's hundreds of times faster.

提交回复
热议问题