vb.net - 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 :)
解决方案
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
推荐阅读
- django - 如何在 django 测试用例中获取测试 http 请求?
- serial-communication - 我们可以从 KaiOS 应用程序通过 USB 串行通信吗?
- spring-boot - liquibase dropFirst 忽略模式
- python - 使用 Ubuntu shell 时出现“HTTP 错误 403:需要 SSL”
- argo-workflows - 有没有办法手动重试 Argo DAG 工作流程中的一个步骤?
- python - 我的 python 函数出错,提示 TypeError: _() 需要 1 个位置参数,但给出了 2 个
- macos - 如何在mac中每个进程打开超过10240个文件?
- reactjs - 单击单选按钮并在单选按钮内显示相应的值,如在 react js 材料 UI 设计中选择的那样
- java - 最大重试次数后异步 HTTP 发布重试和耗尽
- docker - 通过 shell 脚本将文件从本地复制到 docker 容器