A small contribution to this answer. It is better to check the number of bytes read in each block so that the recorded stream is an exact replica of the stream read from SharePoint. See Correction below.
int size = 10 * 1024;
using (Stream stream = file.OpenBinaryStream())
{
using (FileStream fs = new FileStream(@"C:\Users\krg\Desktop\xyz.pptx", FileMode.Create, FileAccess.Write))
{
byte[] buffer = new byte[size];
int nbBytesRead =0;
while((nbBytesRead=stream.Read(buffer, 0, buffer.Length)) > 0)
{
fs.Write(buffer, 0, nBytesRead);
}
}
}
source
share