相当于打开输入为 - 在 VB.NET

Equivalent of Open for input as - in VB.NET

您好,我正在将应用程序从 vb 6 迁移到 .net,但我不知道如何将 Open PATH_IN For Input as intfile(0) 转换为 vb.NET 语法,提前感谢您的帮助,对不起我的英语,这里是代码代码:

 Open PATH_IN For Input As intFile(0) 
For intContador = 1 To intDefinicions - 1
        intFile(intContador) = FreeFile()
        Open Targetes(intContador).Out For Output As intFile(intContador)
Next
    While Not EOF(intFile(0))
        intRegs = intRegs + 1
        Line Input #intFile(0), sRegistre

    If Len(sRegistre) >= 146 Then
            sTipusFitxerEMV = Mid(sRegistre, 144, 3)
            sTipusFitxerEMV = verificarTipusFitxerHOST(sTipusFitxerEMV)
            bTipusFitxerEMV = True
            ciCVV = Mid(sRegistre, 147, 3)
            sRegistre = Left(sRegistre, 143)
        Else
            bTipusFitxerEMV = False
        End If

        sBIN = Left(sRegistre, LEN_BIN)
        bTrobat = False
        For intConta = 1 To intDefinicions - 1
            If Targetes(intConta).BIN = sBIN Then
                bTrobat = True
                sNewReg = "$" & transCaractersEspecials(sRegistre) & Chr(Hex2Dec(22)) & ComposaBanda(sRegistre, Targetes(intConta).Banda)



                If Targetes(intConta).EMV Then
                    sNewReg = sNewReg & ComposaEMV(sRegistre, Targetes(intConta).Identificacio, Targetes(intConta).PEK, Targetes(intConta).Banda, ciCVV)
                Else
                    iPosNoEMV = Len(sNewReg)
                    sNewReg = sNewReg & String2Hex(sNewReg)
                    sNewReg = Mid(sNewReg, 1, iPosNoEMV)
                End If

                If bTipusFitxerEMV And Targetes(intConta).EMV Then
                    escriureFitxerEMV sNewReg & "#END#", intConta, sTipusFitxerEMV
            Else
                    Print #intFile(intConta), sNewReg & "#END#"
            End If

            End If
        Next
        If Not bTrobat Then
            MsgBox "It do not exist" & vbLf & vbCr & sRegistre, vbCritical, "Atention"
    End If
Wend

对于文件读取,您需要将其更改为使用 StreamReader 对象

例如

Using streamReader As System.IO.StreamReader = System.IO.File.OpenText(PATH_IN)
    While Not streamReader.EndOfStream
        sRegistre = streamReader.ReadLine()
        ...
    End While
End Using