I want to read any file as binary 0 and 1 (txt,exe,png,whatever) then i want to do something to this 0 and 1 ones am done i want to recreate that file , if for example that file was .png then i want the new image to be working . with note that i know that changing the 0 and 1 may damage the file but i do know what am doing to this 0 and 1
i can read the file as 0 and 1 with the following code and write it to txt file but what i want is to recreate the original file after editing the 0 and 1 and that file should work
string inputFilename = @"/xx/xxx/xxx/xxx/folder/original.jpg"; string outputFilename = @"/xx/xxx/xxx/xxx/folder/New.txt";
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());
i expect to read anyfile as binary , do something to 0 and 1 , recreate the file again