c# - File I/O with streams - best memory buffer size -
I am writing a small I / O library to assist with a big (hobby) project. A part of this library performs different functions on a file, which is read through the FileStream object. On each streamReader. Read (...) , I prevent an event that will be used in the main app to display progress information. The loop processing is wired, but not very time consuming (this can be just a simple file copy, for example, or encryption may include ...). My main question is: What is the best memory buffer size to use? Thinking about the physical disk layout, I could choose 2K, which would cover a CD sector size and 512 bytes would be a lot of hard disk sector. High above Abstract Tree, you can go for a bigger buffer which can read an entire FAT cluster at a time. I feel with today's PC, I can go for a more hungry hunger option (for example, a couple of MIBs), but then I increase time between UI updates and the user considers less sensitive applications. On the one hand, I am hoping to...