Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Unable to read beyond the end of the stream


Message #1 by "Ashley Pace" <apace@l...> on Thu, 20 Sep 2001 18:15:38
When executing the following code, when it gets to the FileGet line, I get 

an error saying "Unable to read beyond the end of the stream.".  "EOD" is 

declared as a Public Structure.  If anyone can help, please let me know!



iFile1 = FreeFile()

        FileOpen(iFile1, "c:\Temp\1001\endofday.err", OpenMode.Random, , , 

Len(EOD))

        iPosition = 1



        Do While Not EOF(iFile1)

            FileGet(iFile1, EOD, iPosition)

            If EOF(iFile1) Then

                Exit Do

            Else

                sRetValue = sRetValue & "," & CStr(EOD.iDay)

                iPosition = iPosition + 1

            End If

        Loop
Message #2 by "Ashley Pace" <apace@l...> on Fri, 21 Sep 2001 13:15:34
I actually fixed this problem.  Be very careful of your variable usage 

in .Net.  The integer from VB6 is not the same as the integer in .Net.  A 

short is 16-bit the integer in .Net is 32-bit which is the equivalent of a 

long in VB6.  I kept getting the end of stream error because it was trying 

to read too much of the file.  Once I changed my variable to a Short, it 

worked fine!



> When executing the following code, when it gets to the FileGet line, I 

get 

> an error saying "Unable to read beyond the end of the stream.".  "EOD" 

is 

> declared as a Public Structure.  If anyone can help, please let me know!

> 

> iFile1 = FreeFile()

>         FileOpen(iFile1, "c:\Temp\1001\endofday.err", 

OpenMode.Random, , , 

> Len(EOD))

>         iPosition = 1

> 

>         Do While Not EOF(iFile1)

>             FileGet(iFile1, EOD, iPosition)

>             If EOF(iFile1) Then

>                 Exit Do

>             Else

>                 sRetValue = sRetValue & "," & CStr(EOD.iDay)

>                 iPosition = iPosition + 1

>             End If

>         Loop

  Return to Index