c# - Show binary code of external files/program -


one way or another, digital data stored in 0 , 1. that's principle of binary data, guess.

is there method or package can show binary code of file/single-exe-program of how being stored in 0/1 format??

i see like: - import certain, random file - convert it's 0/1 format - store the 1/0-data in txt (streamwriter/binarywriter)

if yes, available in .net language (pref: c#)?

essentially need break 2 steps:

  1. convert file bytes
  2. convert byte binary string

the first step easy:

var filebytes = file.readallbytes(somefilename); 

the second step less straightforward, but still pretty easy:

var bytestring = string.concat(filebytes.select(x => convert.tostring(x, 2).padleft(8, '0'))) 

the idea here select each byte individually, converting each 1 binary string (pad left each 1 8 characters, since many bytes have leading zeroes), , concatenate of single string. (courtesy in part of @xanatos' comment below.)


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -