Question : binary to hex convertion?

ok so hears the deal I want to be able to read a file in form of hex as in the hex that a hex editor was displaying...

example
file w/ the fallowing hex
2B 00 25 01 00 14

will keep comming back as
43 0 37 1 0 20
after loading the file from binary...
any ideas?


rename byte.zip to byte.data seeing it will not allow me to upload to site.


Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Dim myFileStream As FileStream
        Dim intByte As Integer
        Dim lngLoop As Long = 0
        Dim bteRead() As Byte
 
        Try
            myFileStream = File.OpenRead("C:\byte.dat")
            ReDim bteRead(myFileStream.Length)
 
            Do While Not intByte = -1
                intByte = myFileStream.ReadByte()
 
                If intByte <> -1 Then bteRead(lngLoop) = CByte(intByte)
                lngLoop += 1
 
                Dim bytDecimal As System.Byte = intByte
 
                Dim strHex As System.String = Hex(bytDecimal)
                Dim bytHex As System.Byte = "&H" & strHex
 
                MsgBox(bytHex)
 
            Loop
 
            myFileStream.Close()
 
        Catch ex As IOException
            Console.WriteLine(ex.Message)
        End Try
 
    End Sub

Answer : binary to hex convertion?

Please try using the following code:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Dim bytAllBytes() As Byte = System.IO.File.ReadAllBytes("FILEPATH")
Dim strHex As String = String.Empty
 
For Each bytTemp As Byte In bytAllBytes
 
  'For your exact requirements
	strHex &= bytTemp.ToString("X2") & " "
  
  'however, you can use "X4" or "Xn" where replacing "n" with a numeric value will pad that number of zeros in the begining
 
Next
 
MessageBox.Show(strHex)
Random Solutions  
 
programming4us programming4us