How do I read a binary file header?
How do I read a binary file header in VB.Net 2005?
The files were created using VB6 and a user defined type:
Private Type IscImageHeader
'File information stuff.
FileID As String * 5
Columns As Integer
Rows As Integer
NumberOfImages As Integer
StoredDataType As Byte
'Software identification.
SoftwareID As String * 12
SoftwareRevision As Single
'Readout identification.
Readout As String * 5
SerialNumber As String * 10
'Image file creation information.
Program As String
CreationDate As Double
OperatorName As String
ChipTemperature As String
RoomTemperature As String
OtherTestConditions As String
Comment As String
Description As String
'Unit of measure.
UnitOfMeasure As String * 12
CompressionSlope As Double
CompressionIntercept As Double
End Type
Then a variable is create of this type (udt). I could then use the file get and put commands to read and write the header in a single line of code.
Is there an equivalent mechanism in VB.Net 2005? I have to read already existing files.
[1220 byte] By [
DGardner37] at [2007-11-11 10:07:15]

# 1 Re: How do I read a binary file header?
Try this:
Private Structure IscImageHeader
'File information stuff.
<VBFixedString(5)> Public FileID As String
Public Columns As Short
Public Rows As Short
Public NumberOfImages As Short
Public StoredDataType As Byte
'Software identification.
<VBFixedString(12)> Public SoftwareID As String
Public SoftwareRevision As Single
'Readout identification.
<VBFixedString(5)> Public Readout As String
<VBFixedString(10)> Public SerialNumber As String
'Image file creation information.
Public Program As String
Public CreationDate As Double
Public OperatorName As String
Public ChipTemperature As String
Public RoomTemperature As String
Public OtherTestConditions As String
Public Comment As String
Public Description As String
'Unit of measure.
<VBFixedString(12)> Public UnitOfMeasure As String
Public CompressionSlope As Double
Public CompressionIntercept As Double
End Structure
Dim hdr As IscImageHeader
Dim hFile As Integer = FreeFile()
FileOpen(hFile, "d:\path\file.ext", OpenMode.Binary)
FileGet(hFile, hdr)
FileClose(hFile)