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.
Printable View
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.
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.
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.
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
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.Quote:
Originally Posted by wild_bill
2,3,4. Can you write code whitch open hex file like aaa.hex and convert it into string?
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.
Do you see any hex editor. I want have somethink like in all editors window in string.
I want have this:
http://rafzig.pl/Picture 1.png
in string.
Any one can help me?
Oh, so you actually want to see the byte values rather than trying to interpret the byte values as text?
Adjust as required.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())
Quote:
Originally Posted by jmcilhinney
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??
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.
I am using this code that you posted
How would i now save the file?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())
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
This is what the first line of file looks like in hex editor
After i have opened it then saved it with out making any changes this is what it looks likeCode:CON ...e.(aX853932-001..
The code needs to be change from hex before saving it.Code:43 4F 4E 20 01 A8 03 65
Do you see what i mean?
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
After i have opened it then saved it with out making any changes this is what it looks likeCode:CON ...e.(aX853932-001..
The code needs to be change from hex before saving it.Code:43 4F 4E 20 01 A8 03 65
Do you see what i mean?
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