|
-
Dec 17th, 2008, 02:04 PM
#1
Thread Starter
New Member
[2008] How to open HEX file
I have problem, how I can import HEX file to my program in VB .NET? And I have question if I can import, What size of file I can import? I have 200MB - 400MB HEX files?? Can I import so huge files? Thanks for all yours replays.
-
Dec 17th, 2008, 02:15 PM
#2
Re: [2008] How to open HEX file
do you want to read the file, or add it as part of the project. btw - all files are stored as binary, therefore they are all hex, since hex is just a representation of binary.
-
Dec 17th, 2008, 02:50 PM
#3
Re: [2008] How to open HEX file
If you want to view a file in Hex goto, File > Open File, select your file, click the little arrow on the open button, select Open with, and select Binary editor, and hit OK.
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
Dec 17th, 2008, 02:59 PM
#4
Thread Starter
New Member
Re: [2008] How to open HEX file
I write programe. It work that:
1. You chose Hex file
2. Program open hex file and save as string.
3. Program search in Hex some text
4. Program save this string in text file.
I have problem with open file. I want do string function on this hex file, like left, right, mid, replace. Can I do It, If yes How??
So my problem is import HEX as String to VB .NET
-
Dec 17th, 2008, 03:10 PM
#5
Re: [2008] How to open HEX file
1. Research open file dialog
2. Research io.binaryreader
3. Research binary to hex conversion
4. Research io.binarywriter
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
Dec 17th, 2008, 03:22 PM
#6
Thread Starter
New Member
Re: [2008] How to open HEX file
 Originally Posted by wild_bill
1. Research open file dialog
2. Research io.binaryreader
3. Research binary to hex conversion
4. Research io.binarywriter
1. I know how to do it.
2,3,4. Can you write code whitch open hex file like aaa.hex and convert it into string?
-
Dec 17th, 2008, 03:35 PM
#7
Re: [2008] How to open HEX file
Quite possibly no. A string can be either ASCII (one byte per character), Unicode (two bytes per character), or something else (encoded or compressed). If you know that the string is either ASCII or Unicode, then you can convert it easily, as you would be converting a byte array to a string. However, if you don't know how the string is represented in the file, it won't be quite so easy. I suppose you could try it in ASCII and see whether or not it is readable, and if it isn't, then try it in unicode, but it would be best if you knew which it was to start with, and if it is neither ASCII nor Unicode, you may well have a very difficult time converting it.
My usual boring signature: Nothing
 
-
Dec 17th, 2008, 05:22 PM
#8
Thread Starter
New Member
Re: [2008] How to open HEX file
Do you see any hex editor. I want have somethink like in all editors window in string.
I want have this:

in string.
-
Dec 17th, 2008, 06:34 PM
#9
Thread Starter
New Member
Re: [2008] How to open HEX file
-
Dec 17th, 2008, 07:26 PM
#10
Re: [2008] How to open HEX file
Oh, so you actually want to see the byte values rather than trying to interpret the byte values as text?
My usual boring signature: Nothing
 
-
Dec 17th, 2008, 07:33 PM
#11
Re: [2008] How to open HEX file
vb.net Code:
Dim builder As New System.Text.StringBuilder Using reader As IO.FileStream = IO.File.OpenRead("file path here") Dim length As Long = reader.Length Do Until reader.Position = length If reader.Position > 0L Then builder.Append(" "c) End If builder.Append(reader.ReadByte().ToString("X2")) Loop End Using MessageBox.Show(builder.ToString())
Adjust as required.
-
Dec 18th, 2008, 12:08 AM
#12
Thread Starter
New Member
Re: [2008] How to open HEX file
 Originally Posted by jmcilhinney
vb.net Code:
Dim builder As New System.Text.StringBuilder
Using reader As IO.FileStream = IO.File.OpenRead("file path here")
Dim length As Long = reader.Length
Do Until reader.Position = length
If reader.Position > 0L Then
builder.Append(" "c)
End If
builder.Append(reader.ReadByte().ToString("X2"))
Loop
End Using
MessageBox.Show(builder.ToString())
Adjust as required.
Big thx. This is what I want. But I have one requied. I want have this string with out spaces after all pars of binary. If the code is "31 32 32", I want "313232". What i must do??
-
Dec 18th, 2008, 12:10 AM
#13
Re: [2008] How to open HEX file
What you must do is read the code. You may be new but it shouldn't be very hard to work out where the spaces are being added. You can then simply remove the code that does it. Think first, ask questions later.
-
Jan 16th, 2012, 03:33 PM
#14
New Member
Re: [2008] How to open HEX file
I am using this code that you posted
Code:
Dim builder As New System.Text.StringBuilder
Using reader As IO.FileStream = IO.File.OpenRead("file path here")
Dim length As Long = reader.Length
Do Until reader.Position = length
If reader.Position > 0L Then
builder.Append(" "c)
End If
builder.Append(reader.ReadByte().ToString("X2"))
Loop
End Using
MessageBox.Show(builder.ToString())
How would i now save the file?
-
Jan 16th, 2012, 07:15 PM
#15
Re: [2008] How to open HEX file
 Originally Posted by Sutton2k9
I am using this code that you posted
Code:
Dim builder As New System.Text.StringBuilder
Using reader As IO.FileStream = IO.File.OpenRead("file path here")
Dim length As Long = reader.Length
Do Until reader.Position = length
If reader.Position > 0L Then
builder.Append(" "c)
End If
builder.Append(reader.ReadByte().ToString("X2"))
Loop
End Using
MessageBox.Show(builder.ToString())
How would i now save the file?
As you can see from reading and running the code, 'builder.ToString()' returns a String containing the hex data. A String is a String. How would you usually save a String to a file?
http://www.google.com.au/search?q=sa...ient=firefox-a
-
Jan 16th, 2012, 09:15 PM
#16
New Member
Re: [2008] How to open HEX file
 Originally Posted by jmcilhinney
This is what the first line of file looks like in hex editor
Code:
CON ...e.(aX853932-001..
After i have opened it then saved it with out making any changes this is what it looks like
Code:
43 4F 4E 20 01 A8 03 65
The code needs to be change from hex before saving it.
Do you see what i mean?
-
Jan 16th, 2012, 09:16 PM
#17
New Member
Re: [2008] How to open HEX file
I know how to save it as a string i want to open it change a hex value then save it not as a string.
I think it has to be changed back into bytes
This is what the first line of file looks like in hex editor
Code:
CON ...e.(aX853932-001..
After i have opened it then saved it with out making any changes this is what it looks like
Code:
43 4F 4E 20 01 A8 03 65
The code needs to be change from hex before saving it.
Do you see what i mean?
-
Jan 16th, 2012, 09:26 PM
#18
Re: [2008] How to open HEX file
 Originally Posted by Sutton2k9
I know how to save it as a string i want to open it change a hex value then save it not as a string.
I think it has to be changed back into bytes
This is what the first line of file looks like in hex editor
Code:
CON ...e.(aX853932-001..
After i have opened it then saved it with out making any changes this is what it looks like
Code:
43 4F 4E 20 01 A8 03 65
The code needs to be change from hex before saving it.
Do you see what i mean?
Either it's a hex file or it's not. If you open it in Notepad do you see pairs of hex characters? If so then it's a hex file and you already have your answer. If not then it's not a hex file.
-
Jan 16th, 2012, 09:38 PM
#19
New Member
Re: [2008] How to open HEX file
Don't worry i have fixed it i was after a way to change the hex back to bytes so i could save them again but i worked it out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|