Click here to Skip to main content
13,047,131 members (60,639 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I want to work with Hex numbers.
I want to Read a file(ex. text file) and store their character in HEX Type.
and then do some calculations on these data.
please help me.
thank you.
Posted 30-Apr-13 9:07am
richcb 30-Apr-13 15:09pm
Ok, go ahead and do that.
ThePhantomUpvoter 30-Apr-13 15:10pm
Help you with what? Can you not read a file? Can you not declare a byte array? What have you tried? Where are you stuck? What is it that you think a "HEX" type is?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First off, there is no HEX type - and it's unlikely there ever would be, since Hex is representation of a number, rather than a different type of numbering altogether.

If you mean you want to work on files in their raw form, then just use bytes:
byte[] data = File.ReadAllBytes(@"D:\Temp\myFile.txt");
Will read your file into normal 8 bits bytes without any translation or text interpretations going on.
for (int i = 0;i < data.Length; i++)
   data ^= (byte) i;
File.WriteAllBytes(@"D:\Temp\MyUselessFile.txt", data);
Will alter each byte individually, and write them back out to a new file, that is pretty much useless. (Reading it in and running through the same code will restore it though).

Is that the kind of thing you were thinking of?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100