Click here to Skip to main content
13,504,308 members

Response to: Read Hex Value from file & write it to another file with the same value?

Revision 1
Read File as bytearray then convert them into hex:

Private Function GetBytes(ByVal filename As String) As Byte()
    Dim fs As New FileStream(filename, FileMode.Open, FileAccess.Read)
    ' Create a byte array of file stream length
    Dim ImageData As Byte() = New Byte(fs.Length - 1) {}
    'Read block of bytes from stream into the byte array
    fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length))
    'Close the File Stream
        'return the byte data
    Return ImageData
End Function

Private Function Bytes_To_Hex(ByVal bytes_Input As Byte()) As String
        Dim strTemp As New StringBuilder(bytes_Input.Length * 2)
        For Each b As Byte In bytes_Input
        Return strTemp.ToString()
End Function
Posted 27-Jan-13 17:39pm by Kuthuparakkal.
Tags: ,
  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180417.1 | Last Updated 5 Nov 2009
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid