Read File Bytes into String
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Hi, I been having a pain in the butt to find out how could I load and read bytes into string the notepad way.
I know already howto bind data into an existing file.
This is how I would like to get it: All you gotta do is to find how can I load data into strings notepad way. Thank you, bye.
REWARD = 50 Credits
I know already howto bind data into an existing file.
This is how I would like to get it: All you gotta do is to find how can I load data into strings notepad way. Thank you, bye.
REWARD = 50 Credits
You do not have the required permissions to view the files attached to this post.
You could encode it into a hex string:
Code: Select all
Then to convert that string back to binary you can use:
Dim bytes As Byte() = IO.File.ReadAllBytes("file.exe")
Dim encoded As String = ""
For i As Integer = 0 To bytes.Length - 1
encoded += bytes(i).ToString("X2")
Next
MsgBox(encoded)
Code: Select all
15/6/11 Edit: Improved efficiency. Dim newBytes As List(Of Byte) = New List(Of Byte)
For i As Integer = 0 To encoded.Length - 1 Step 2
Dim current As Byte = Byte.Parse(encoded.Substring(i, 2), NumberStyles.AllowHexSpecifier)
newBytes.Add(current)
Next
Dim decoded As Byte() = newBytes.ToArray()
Last edited by mandai on Wed Jun 15, 2011 5:50 pm, edited 4 times in total.
I'm sorry, but thats not I need. I need to read bytes into for an example textbox like MS Notepad does. Thats how I could find & read data I put there like Hello World
I already know how to bind text end of the file and it would still work
I already know how to bind text end of the file and it would still work
Notepad displays the file as a character array, not a byte array.
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023