I want to make a method that takes any file and reads it as an array of 0s and 1s, i.e. its binary code. I want to save that binary code as a text file. Can you help me? Tha
Quick and dirty version:
byte[] fileBytes = File.ReadAllBytes(inputFilename); StringBuilder sb = new StringBuilder(); foreach(byte b in fileBytes) { sb.Append(Convert.ToString(b, 2).PadLeft(8, '0')); } File.WriteAllText(outputFilename, sb.ToString());