What would be the fastest way to concatenate three files in C#?

后端 未结 7 1789
滥情空心
滥情空心 2020-11-29 07:40

I need to concatenate 3 files using C#. A header file, content, and a footer file, but I want to do this as cool as it can be done.

Cool = really small code or reall

7条回答
  •  伪装坚强ぢ
    2020-11-29 08:11

    void CopyStream(Stream destination, Stream source) {
       int count;
       byte[] buffer = new byte[BUFFER_SIZE];
       while( (count = source.Read(buffer, 0, buffer.Length)) > 0)
           destination.Write(buffer, 0, count);
    }
    
    
    CopyStream(outputFileStream, fileStream1);
    CopyStream(outputFileStream, fileStream2);
    CopyStream(outputFileStream, fileStream3);
    

提交回复
热议问题