See this thread specifically post#2 by Erel for a more concise solution:
This code is no longer needed. Use File.WriteBytes / ReadBytes. Write an array of bytes to a file and read a file into an array of bytes. Sub BytesToFile (Dir As String, FileName As String, Data() As Byte) Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)...
www.b4x.com
Normally, you should not credit your thread with the solution. You found the solution given to you by
@mangojack. Therefore, the solution should be mj's post in the thread you were referring to in your post #2.