S
Shaun Merrill
Hey, here is my code. I am trying to read a file into a byte array. Please
show me how this can work.
Obviously I need to read into a dynamic array because it could read any
file. So why does VB.NET give me the ability to read into a Byte Array if
it doesn't allow me to use a variable sized array?
Dim i As Short = FreeFile()
FileSystem.FileOpen(i, Filename, OpenMode.Binary, OpenAccess.Read,
OpenShare.Default)
Dim iByteArray() As Byte
ReDim iByteArray(LOF(i))
FileSystem.FileGet(i, iByteArray, True)
FileSystem.FileClose(i)
This code bombs on FileGet(), throwing an EndOfStream exception "Unable to
read beyond the end of the stream."
Even if I use no Redim statement, I get "Cannot determine array type because
it is Nothing."
Obviously, the ArrayIsDynamic parameter is set to True. What am I doing
wrong?!?
~ Frustrated
show me how this can work.
Obviously I need to read into a dynamic array because it could read any
file. So why does VB.NET give me the ability to read into a Byte Array if
it doesn't allow me to use a variable sized array?
Dim i As Short = FreeFile()
FileSystem.FileOpen(i, Filename, OpenMode.Binary, OpenAccess.Read,
OpenShare.Default)
Dim iByteArray() As Byte
ReDim iByteArray(LOF(i))
FileSystem.FileGet(i, iByteArray, True)
FileSystem.FileClose(i)
This code bombs on FileGet(), throwing an EndOfStream exception "Unable to
read beyond the end of the stream."
Even if I use no Redim statement, I get "Cannot determine array type because
it is Nothing."
Obviously, the ArrayIsDynamic parameter is set to True. What am I doing
wrong?!?
~ Frustrated