Read (with .FileGet file system) VB6 write file (written using Put) with C #

I need to read data from an obsolete database file created in Visual Basic 6. From the old software, I found that the file was written using Putand passing records as parameters to a function Put. These structures are defined as follows:

Type THE_TYPE
    FIELD_1 As Single
    FIELD_2 As String * 20
    FIELD_3(1 To 50) As Single
    FIELD_4(1 To 10) As String * 1
End Type

My types are bigger and more complex, but I inserted into the THE_TYPEdifferent definitions that are in my project. I found that import Microsoft.VisualBasicgives me access to VB functions similar to those used to write the file, so I open and close the file with FileSystem.OpenFile()and .CloseFile();, now I need to finally read the data contained in it and since the original function was:

Public RecordContent As THE_TYPE
[...] 
Get #1, recordNumber, RecordContent 

, - , , Microsoft.VisualBasic.FileSystem.FileGet().
, , , , , VB6 THE_TYPE? .FileGet(), ?

+7
1

VB.NET. , FileGet, , .

Structure THE_TYPE
    Public FIELD_1 As Single
    <VBFixedString(20), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=20)> Public FIELD_2 As String
    <VBFixedArray(49)> Public FIELD_3 As Single()
    <VBFixedArray(9)> Public FIELD_4 As Char()
End Structure

, , .

:

Dim d As System.ValueType = New THE_TYPE()

FileOpen(1, "...", OpenMode.Random, OpenAccess.Read, OpenShare.Default, 234)
FileGet(1, d, 1)
FileClose(1)

234 - VB6. VB.NET, .

+7

All Articles