Error BC30829 'Get' statements are no longer supported - Converting from vb6 to vb.net

Viewed 407

I am converting a project from vb6 to vb.net.
I converted most of the part but stuck on a line.

VB6 code :

    Do While Not EOF(FileO)
        Get #FileO, , ByteBuffer
        If Loc(FileO) < LOF(FileO) Then
            ByteCounter = ByteCounter + 64
        End If
    Loop

VB.NET Code :

  Do While Not EOF(FileO)
            Get(#FileO, , ByteBuffer) '----------> PROBLEM HERE
            If Loc(FileO) < LOF(FileO) Then
                ByteCounter = ByteCounter + 64
            End If
        Loop

I am getting problem over the get statement.
Get(#FileO, , ByteBuffer)

Error I am facing is :

Error BC30829 'Get' statements are no longer supported. File I/O functionality is available in the 'Microsoft.VisualBasic' namespace.

What is replacement for GET statement?? How to apply?
Thanx :)

2 Answers
 Option Explicit On

 Imports System
 Imports System.IO

 Module Module1
     Sub Main()
         Dim ByteBuffer As Byte()

         Using myFile As BinaryReader = New BinaryReader(File.Open("TESTFILE.BIN", FileMode.OpenOrCreate))
             While myFile.BaseStream.Position < myFile.BaseStream.Length
                 ByteBuffer = myFile.ReadBytes(64)
             End While

             myFile.Close()
         End Using
     End Sub

End Module

As a jump start - you should use your ide and the object browser to see what you can get from this:

// make sure the read buffer is big enough
string testReadData = "".PadRight(128);
int filenumber = VB6FileSystem.FreeFile();
VB6FileSystem.FileOpen(filenumber, @"c:\temp\test.dat", VB.OpenMode.Random, RecordLength: 128);
// Write some test data ....
VB6FileSystem.FilePut(filenumber, "Testdaten 1", 1, true);
VB6FileSystem.FilePut(filenumber, "Testdaten 4", 4, true);
VB6FileSystem.FilePut(filenumber, "Testdaten 14", 14, true);
// Read some data ...
VB6FileSystem.FileGet(filenumber, ref testReadData, 14, true);
VB6FileSystem.FileClose(filenumber);

I think, you can grasp it

Related