Click here to Skip to main content
11,409,854 members (62,861 online)
Click here to Skip to main content
Alternative Answer

Tagged as

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

, 27 Jan 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
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 -...
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
    fs.Close()
        '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
            strTemp.Append(Conversion.Hex(b))
        Next
        Return strTemp.ToString()
End Function
You can use another stringbuilder to store hex strings from each file-in the pattern you like- and then write stringbuilder to files.

License

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

Share

About the Author

Kuthuparakkal
Business Analyst
United States United States
No Biography provided

Comments and Discussions

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.5 | Last Updated 27 Jan 2013
Article Copyright 2013 by Kuthuparakkal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid