Results 1 to 3 of 3

Thread: Hex / Binary

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Hex / Binary

    Code:
    byte[] buff = new byte[4];
    buff[0] = 0x34;
    buff[1] = 0x23;
    buff[2] = 0x00;
    buff[3] = 0xF2;
    
    
    FileStream fs = new FileStream("hex.bin", FileMode.Create, FileAccess.ReadWrite);
    BinaryWriter bw = new BinaryWriter(fs);
    bw.Write(buff);
    bw.Close(); 
    Console.WriteLine("Written to file : hex.bin");
    Right. That writes (34 23 00 F2) to a file in binary (specifically NOT text).

    I would like to read a hex number (lets just say 342300F2) from a text file and encode that same hex number to a binary file. I cant work out how to process the text into binaray. Any ideas?
    Last edited by francisstokes; Nov 3rd, 2009 at 10:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width