Write File byte array content to a file by file name - CSharp System

CSharp examples for System:Byte Array

Description

Write File byte array content to a file by file name

Demo Code

/*//from  ww  w  .j  a  va 2  s . com
Copyright ?2009 John Allberg

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
using System.IO;
using System.Security.Cryptography;
using System.Diagnostics;
using System;

public class Main{
    public static void WriteFile(byte[] bytes, string filename)
      {
         System.IO.FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
         
         fs.Write(bytes, 0, bytes.Length);

         fs.Flush();
         fs.Close();
      }
}

Related Tutorials