Author: Alessio Saltarin
URL: http://www.bytemycode.com/snippets/snippet/333/
Write a set of bytes into a ‘so-called’ binary file. The point is that we use BinaryWriter here and we have a byte array as input.
/*
Write a binary file
<param name="filePath">Full path of file to be written</param>
Teturn True, if success
*/
public bool WriteBinaryFile(string filePath, byte[] contents)
{
bool okok = true;
try
{
using (FileStream fs = new FileStream(filePath, FileMode.CreateNew))
{
using (BinaryWriter w = new BinaryWriter(fs))
{
w.Write(contents);
}
}
}
catch (IOException e)
{
okok = false;
}
return okok;
}










