VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Trouble reading binary file Posted by PeterHh on 25 Jun 2012 at 5:05 AM
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

	Public Structure t_LASHeader
		'Header 1.1
        <VBFixedString(5), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=5)> Public FileSig() As Char
		Dim FileSource As Short
		Dim reserved As Short
		Dim GUID1 As Integer
		Dim GUID2 As Short
		Dim GUID3 As Short
        <VBFixedString(9), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=9)> Public GUID4() As Char
		Dim VersionMajor As Byte
		Dim VersionMinor As Byte
        <VBFixedString(33), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=33)> 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



I made a button to start reading

    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:\temp\224102_000042.las"
            FileOpen(ff, s, OpenMode.Binary, OpenAccess.Read)
            FileGet(ff, LasHeader)
            FileClose(ff)
    End Sub



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...

Peter





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.