Read the error message again. Your byte array is called
fileBytes
, but you are trying to write an uninitalized field called
byteArr
into the file.
Your code can be simplified to:
using System;
using System.IO;
internal static class Program
{
static void Main()
{
byte[] fileBytes = File.ReadAllBytes(@"C:\Users\Sniper\Desktop\array3.bin");
File.WriteAllBytes(@"C:\Users\Sniper\Desktop\array3.txt", fileBytes);
}
}
But this code makes no sense. You are simply copying the file and changing the extension. The bytes from the source file almost certainly won't make sense as text.