I'm assuming that you want to know about performing the actual save and not about getting the binary from the database. I'm making this assumption based on the perception that you have the wherewithal to put the data and therefore have the wherewithal to get the data out.
Here's the code to save the file to disk.
/// <summary>
/// Saves binary data from a database record to a path on the file system.
/// </summary>
/// <param name="recordId">
/// The identifier of the record whose binary data will be saved.
/// </param>
private void SaveFileLocal( long recordId )
{
byte[] data = null;
string filePath = string.Empty;
string directoryPath = string.Empty;
/**
* TODO: Get data from database, this sample assumes
* you have data in the "data" variable and a full file path
* in the "filePath" variable.
**/
if( data != null && !string.IsNullOrEmpty( filePath ) )
{
directoryPath = Path.GetDirectoryName( filePath );
if( !Directory.Exists( directoryPath ) )
Directory.CreateDirectory( directoryPath );
File.WriteAllBytes( filePath, data );
}
}
Hope this helps.
"There's a way to do it better - find it." - Thomas Edison