首页 > 解决方案 > Error BC30829 'Get' statements are no longer supported - Converting from vb6 to vb.net

问题描述

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 :)

标签: vb.netvb6vb6-migration

解决方案


 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

推荐阅读