document.write('<div class="csharp" style="font-family: monospace;"><br />');
document.write('<br />');
document.write('<span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span><br />');
document.write('<span style="color: #008080; font-style: italic;">/// Write a binary file</span><br />');
document.write('<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span><br />');
document.write('<span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;filePath&quot;&gt;Complete path to the file to be written&lt;/param&gt;</span><br />');
document.write('<span style="color: #008080; font-style: italic;">/// &lt;returns&gt;True, if file was correctly saved.&lt;/returns&gt;</span><br />');
document.write('<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">bool</span> WriteBinaryFile<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> filePath, <span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> contents<span style="color: #000000;">&#41;</span><br />');
document.write('<span style="color: #000000;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">bool</span> okok = <span style="color: #0600FF;">true</span>;&nbsp; <span style="color: #008080; font-style: italic;">// ok, file written</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; FileStream fs = <span style="color: #0600FF;">null</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; BinaryWriter w = <span style="color: #0600FF;">null</span>;<br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">try</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fs = <a target="_blank"&nbsp; href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> FileStream<span style="color: #000000;">&#40;</span>filePath, FileMode.<span style="color: #0000FF;">CreateNew</span><span style="color: #000000;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w = <a target="_blank"&nbsp; href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> BinaryWriter<span style="color: #000000;">&#40;</span>fs<span style="color: #000000;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>contents<span style="color: #000000;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>IOException e<span style="color: #000000;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; okok = <span style="color: #0600FF;">false</span>;&nbsp; <span style="color: #008080; font-style: italic;">// houston, we have a problem</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">finally</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>w!=<span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>fs!=<span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fs.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />');
document.write('<br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> okok;<br />');
document.write('<span style="color: #000000;">&#125;</span><br />');
document.write('<br />');
document.write('&nbsp;</div>');
document.write('<br />&nbsp;<br /><div style="font-size: 12px">Brought to you by the community at <a href="http://www.bytemycode.com/snippets/snippet/333/1/" target="_blank">byteMyCode</a>.</div>');
