Relative Content

Tag Archive for c#.netio

Why is reading bytes here so slow compared to copying the file?

I’m trying to read a whole file’s bytes into memory; for now, I’m doing nothing with it. Reading the file with FileInfo.OpenRead combined with a StreamReader is going very slowly; about 30 seconds as opposed to only 4 seconds to copy/paste the file from one hard drive to another in Explorer. Why would it be so slow to read it into memory? The example code: