How to write File from Byte Array

To Write File Form Byte array use below Code
// File name contain Full fule Path or FileName

public bool ByteArrayToFile(string _FileName, byte[] _ByteArray)
{
try
{

System.IO.FileStream _FileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write);
_FileStream.Write(_ByteArray, 0, _ByteArray.Length);
_FileStream.Close();
return true;
}
catch (Exception _Exception)
{
Console.WriteLine(“Exception caught in process: {0}”, _Exception.ToString());
}
return false;
}

 

Leave a comment