Trouble reading binary file

I'm a VB6 programmer, but VB6 can't read big binary files. I converted my VB6 code in VB.NET, but experience trouble when I want to read a binary file.

I use a type (structure) t_LASHeader

[color=Blue][code] Public Structure t_LASHeader
'Header 1.1
Public FileSig() As Char
Dim FileSource As Short
Dim reserved As Short
Dim GUID1 As Integer
Dim GUID2 As Short
Dim GUID3 As Short
Public GUID4() As Char
Dim VersionMajor As Byte
Dim VersionMinor As Byte
Public SystemIdentifier() As Char
Dim FileCreationDoY As Short
Dim FileCreationYear As Short
Dim HeaderSize As Short
Dim Offset2PointData As Integer
Dim NRVarLengthRecords As Integer
Dim PointDataFormatId As Byte
Dim PointDataRecordLength As Short
Dim NrPointRecords As Integer
Dim NrPointsbyReturn1 As Integer
Dim NrPointsbyReturn2 As Integer
Dim NrPointsbyReturn3 As Integer
Dim NrPointsbyReturn4 As Integer
Dim NrPointsbyReturn5 As Integer
End Structure[/code]

I made a button to start reading

[color=Blue][code] Private Sub cmdStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdStart.Click

Dim LasHeader As t_LASHeader
Dim ff As Short

ff = FreeFile()
s="c: emp224102_000042.las"
FileOpen(ff, s, OpenMode.Binary, OpenAccess.Read)
FileGet(ff, LasHeader)
End Sub[/code]

I get an error when it reaches FileOpen (ArgumentOutOfRangeException was unhandled). I used the code from a thread on this forum, dated 2003, so it should work... What am I doing wrong?

The LAS-file is a file of about 3Gb. In VB6 I use a pointer, but it is limited to a long, while I need bigger...


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!