FileGet: Unable to read beyond the end of the stream.


  • I am trying to use the method FileGet to populate a type library from a text file.  This text file was created by a legacy application using vb6.  In the vb6 code, the Put method was used to create this file by dumping the type library into the file.  I'm using the same type library to parse back into using the FileGet method.  The only difference is that the type library is now an interop dll.  When I use the FileGet, it works for most of the files that I'm trying to read.  However, there are a few that give me the error:  "Unable to read beyond the end of the stream."  Does anyone know what would cause this error and how I can fix it?  I've already tried to add a space and a line break at the end of the file.  This did not work.  I've searched for the solution but have not found anything that has worked.  Any help would be greatly appreciated!

    Here is part of the code that created the file (legacy vb6 code):


    Public Function SaveReport(Optional sFilename As String = sEmpty, Optional bAddToMRU As Boolean = True, Optional bStoreFilename As Boolean = True) As Boolean
     On Error GoTo SaveReport_Error
     Dim iFile As Integer
     Dim intFilterIndex As Integer
     Dim strTemp As String
      strTemp = LCase$(Right$(sFilename, 4))
    160 If strTemp <> ".rpt" And strTemp <> ".avr" And strTemp <> ".tmr" And strTemp <> ".tab" And strTemp <> ".csv" And strTemp <> ".ebx" Then GoTo SaveReport_Error:
     'Open and populate file
    310 iFile = FreeFile
    320 Open sFilename For Binary As iFile
    330 Put iFile, , ADReport
    340 Close iFile
    380 SaveReport = True
    400 On Error GoTo 0
    410 Exit Function
     Select Case Err.Number
      Case 0
       MsgBox "The filename specified does not seem valid. Please specify a valid filename." + CStr(Err.Number), vbCritical, "File Error"
      Case Else
       MsgBox "An abnormal error has occurred running this program: (" + CStr(Erl) + ") " + CStr(Err.Number) + " - " + Err.Description, vbCritical, "frmCompliance_SaveReport Error"
     End Select
     SaveReport = False
    End Function


    Here is the code that I've written to populate the type library from the file:


    Public Function ParseReport(ByVal sFileName As String) As MSXML2.IXMLDOMNode
      On Error GoTo ParseReport_Error
      Dim iFile As Short
      Dim ADReport As ADTYPESTLB20Lib.tagUsrADReport
      Dim ReportNode As MSXML2.IXMLDOMNode
      ' Open and populate file.
      If sFileName <> sEmpty Then
       iFile = FreeFile()
       FileOpen(iFile, sFileName, OpenMode.Binary, OpenAccess.Read)
       FileGet(iFile, ADReport)
      End If
      ParseReport = BuildRecordNodes(ADReport)
      On Error GoTo 0
      Exit Function
      Select Case Err.Number
       Case Else
        MsgBox("An abnormal error has occurred running this program: " & CStr(Err.Number) & " - " & Err.Description, MsgBoxStyle.Critical, "ParseReport_Error")
      End Select
     End Function


    The exception occurs on this line:

    FileGet(iFile, ADReport)




    Monday, October 25, 2010 2:41 PM

All replies

  • Hello jsh2432,

    Thanks for your post.

    If I understand your problem clearly, do you want to use the VB.NET method FileGet in VB6 application? If so, I suggest you could post you problem on VB6 forum for better support.

    For Visual Basic 6 questions, please read:

    Thanks for your understanding.

    Best regards,
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact

    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. Thanks
    Friday, October 29, 2010 2:37 AM
  • Hi Liliane,

    Actually, I want to use the VB6 Get method in VB.NET, which is the FileGet method.  I'm writing a report import tool that takes old reports files (created in VB6 using the Get method) and parses them into the object they were created with.  Once I get the object filled, I'm serializing it and storing it in a database to be used by a new application that displays these reports in a different format.



    Friday, October 29, 2010 12:15 PM
  • I dont know if yall wil look at this,but when i try to luanch an application ''Profile Editor" and load my save,it gives me a unnable to read end of stream error,here is the full report

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
       at System.IO.__Error.EndOfFile()
       at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
       at System.IO.BinaryReader.ReadUInt16()
       at LeonSaunders.Xbox.IO.x6a9127a72944bc9b.xdb264d863790ee7b(EndianType xa0690911073b0985)
       at LeonSaunders.Xbox.IO.x6a9127a72944bc9b.xc6cf3ecf5ca5ba53()
       at LeonSaunders.Xbox.Profile.xfb9c41ec51f1b40f.xe0be0a4f79fc1484()
       at LeonSaunders.Xbox.Profile.x4c26693615a3abcc.x49cfcea60e20759e()
       at ProfileEditor.x210ff09a2516b1a7.x09cac8903b284595(String xa11af9961708073c)
       at ProfileEditor.x210ff09a2516b1a7.xec63924cfc3568e2(Object xe0292b9ed559da7d, EventArgs xfbf34718e704c6bc)
       at DevComponents.DotNetBar.BaseItem.RaiseClick(eEventSource source)
       at DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
       at DevComponents.DotNetBar.PopupItem.InternalMouseUp(MouseEventArgs objArg)
       at DevComponents.DotNetBar.ButtonItem.InternalMouseUp(MouseEventArgs objArg)
       at DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
       at DevComponents.DotNetBar.ItemContainer.InternalMouseUp(MouseEventArgs objArg)
       at DevComponents.DotNetBar.ItemControl.OnMouseUp(MouseEventArgs e)
       at DevComponents.DotNetBar.RibbonBar.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at DevComponents.DotNetBar.ItemControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Loaded Assemblies **************
        Assembly Version:
        Win32 Version: 2.0.50727.3625 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
        Assembly Version: 2.0.2604.0
        Win32 Version: 2.0.2604.0
        CodeBase: file:///C:/Documents%20and%20Settings/Shannon/Desktop/jordans%20shortcuts/PE2%20CRACKED/ProfileEditor.exe
        Assembly Version:
        Win32 Version: 2.0.50727.3623 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/
        Assembly Version:
        Win32 Version: 2.0.50727.3631 (GDR.050727-3600)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/
        Assembly Version:
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/
        Assembly Version:
        Win32 Version:
        CodeBase: file:///C:/Documents%20and%20Settings/Shannon/Desktop/jordans%20shortcuts/PE2%20CRACKED/DevComponents.DotNetBar2.DLL
        Assembly Version:
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/
        Assembly Version:
        Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/
        Assembly Version:
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/
        Assembly Version: 1.6.3511.33600
        Win32 Version: 1.6.3511.33600
        CodeBase: file:///C:/Documents%20and%20Settings/Shannon/Desktop/jordans%20shortcuts/PE2%20CRACKED/LeonSaunders.DLL

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the section.
    The application must also be compiled with debugging

    For example:

        < jitDebugging="true" />

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.


    Sunday, March 11, 2012 7:44 PM
  • 1.) Get the number of bytes requested and

    2.) The exact size of the file

    3.) And the number of bytes already read

    and come back.


    "MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me

    Sunday, March 11, 2012 11:14 PM
  • Hi Liliane,

    Actually, I want to use the VB6 Get method in VB.NET, which is the FileGet method.  I'm writing a report import tool that takes old reports files (created in VB6 using the Get method) and parses them into the object they were created with.  Once I get the object filled, I'm serializing it and storing it in a database to be used by a new application that displays these reports in a different format.



    Hi J. Hamman,

    This thread has resurfaced from over a year ago.

    Anyway, should you come back to this, please see this thread for an example of using




    in Vb.Net



    profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers

    Click this link to see the NEW way of how to insert a picture into a forum post.

    Installing VB6 on Windows 7

    App Hub for Windows Phone & XBOX 360 developers.

    Sunday, March 11, 2012 11:52 PM