This VB Express code demostrates how is possible to load binary files into byte arrays and how to c
This VB Express code demostrates how is possible to load binary files into byte arrays and how to convert and manipulate them as strings
Rate This VB Express code demostrates how is possible to load binary files into byte arrays and how to c
(1(1 Vote))
'This is very important for loading and saving without corruption
Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1")
'Load first file
myArray = System.IO.File.ReadAllBytes("C:\file1.bin")
s1 = enc.GetString(myArray)
'Load second file and join the two contents
Erase myArray
myArray = System.IO.File.ReadAllBytes("C:\file2.bin")
s2 = enc.GetString(myArray)
'Concatenate using a custom separator
s = s1 & "<MYSEPARATOR>" & s2
'Save all in a new file
Erase myArray
myArray = enc.GetBytes(s)
System.IO.File.WriteAllBytes("C:\joinedFiles.bin", myArray)
'Reload the joined file
myArray = System.IO.File.ReadAllBytes("C:\joinedFiles.bin")
s = enc.GetString(myArray)
'Rebuild the two original files
Dim sp() As String = Split(s, "<MYSEPARATOR>")
'Save first file
Erase myArray
myArray = enc.GetBytes(sp(0))
System.IO.File.WriteAllBytes("C:\newfile1.bin", myArray)
'Save the second one
Erase myArray
myArray = enc.GetBytes(sp(1))
System.IO.File.WriteAllBytes("C:\newfile2.bin", myArray)
This VB Express code demostrates how is possible to load binary files into byte arrays and how to c Comments
No comments yet — be the first to post one!
Post a Comment