Saturday, May 30, 2009

Write a binary file

/*
Write a binary file

Full path of file to be written
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;
}

No comments:

Post a Comment