How to write a byte array to a File in C# ?

If you want to write a byte array to a file in C# , you can use the File.WriteAllBytes . Below is a code snippet demonstrating this.

How to write a byte array to a File in C# ?

using System;
using System.Collections.Generic;
using System.IO;

namespace ACCode
{
    class Program
    {
        static void Main(string[] args)
        {
            string pathOfFile = "test.txt";
            byte[] byteArray = GetByteArray();
            // Write the byte array to the file.
            File.WriteAllBytes(pathOfFile, byteArray);
            Console.ReadLine();
        }
        
    }
  
}