Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a hex file. i read data.if i am reading as a character in that first line contain :020000040000FA and at some places have same character but maximum lines containing
:10000000B80C001061020000690200006B020000E1 i want to read from 1st line and then second and further on. and want to read only data block that is skip first 9 char included : and last 2 between this have data block like for first line :020000040000FA in this is 0000 is data block and same in same second line :10000000B80C001061020000690200006B020000E1 i this data block is
B80C001061020000690200006B020000. so how may i read and append each line data block.
Posted
Updated 31-Oct-13 2:45am
v3
Comments
Stephen Hewison 31-Oct-13 8:46am    
What have you tried so far? What problems have you run into?
CPallini 31-Oct-13 9:10am    
What's the purpose of your requirements? Skipping the first 9 characters, your would throw away imoprtant pieces of info.

Its hard to understand what it is you really want to do. Can you please rephrase your question.
Take a look at StreamReader class and Substring method in the string object.
 
Share this answer
 
You already posted this question at hex file parser in c #[^].
However, I answered a similar query yesterday so here is the code to convert it:
C#
int i = 0;
int index = 0;
byte[] hexBytes = new byte[sourceLine.Length /2];
do
{
    string hs = sourceLine.Substring(index, 2);
    hexBytes[i] = (byte)int.Parse(hs, System.Globalization.NumberStyles.AllowHexSpecifier);
    i++;
    index += 2;
} while (index < sourceLine.Length);
// hexBytes now contains the converted data 

Read from the file and then copy the characters you are interested in into sourceLine and use the above code to convert it to its original binary values.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900