I'm learning to program in VB.NET, and I'm trying to manipulate an executable
My project asks me to cut a byte variable (which I got thanks to File.ReadAllytes) in two parts, to then be able to "stick" them in another part of the code.
I thought about converting my byte array to string, then split (using .Split), and finally converting it to a byte array, but my executable no longer works: converting to a string kills some character in my executable, making it obsolete.
I found this post: Split a byte array at a delimiter
..but the problem is that he works in C# and I feel at my level of real difficulty to convert its code into vb.net.
In summary, here are the steps of my program:
- Read all bytes with
File.ReadAllytes - Split this byte array on a regular basis. The seperator will not be a chain, but the half of the array.
- Group the channels and execute
I have try this for split my executable in two byte variable, but i block:
Bytes_Executable = IO.File.ReadAllBytes(File1)
Dim Separator As Integer = Bytes_Executable.Length / 2
MsgBox(Separator)
Dim Sortie = {}
Dim Sortie2 = {}
Array.Copy(Bytes_Executable, 0, Sortie, 0, Separator)
Array.Copy(Bytes_Executable, Separator, Sortie2, 0, Bytes_Executable.Length)
Indeed, I've got this error: The destination table is not long enough. Check destIndex and the length, as well as the lower limits of the array.
This error points this line:
Array.Copy(Bytes_Executable, Separator, Sortie2, 0, Bytes_Executable.Length)
Thank you in advance!