Вот идеал:
using (var fs = new FileStream(SaveLocation, FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
, что примерно эквивалентно:
FileStream fs = null;
try
{
fs = new FileStream(SaveLocation, FileMode.Create);
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
finally
{
if (fs != null)
{
((IDisposable)fs).Dispose();
}
}
с использованием , более читабельным.
ОБНОВЛЕНИЕ:
@ aron, теперь, когда я думаю,
File.WriteAllBytes(SaveLocation, result.DocumentBytes);
выглядит даже красивее, чем идеал: -)