I want to read an exe file in my C# code then decode as base64.
I am doing it like this
FileStream fr = new FileStream(@"c:\1.exe", FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader sr = new StreamReader(fr);
fr.Read(data, 0, count);
But the problem is that when I write this file the written file gets corrupted.
When analyzing in hex workshop code value 20 in hex is being replaced by 0.
A StreamReader should be used only with text files. With binary files you need to use directly a FileStream or: