2
Answers

get Bios number code from vb.net to C#

brss

brss

11y
1.4k
1
Hello All, i need your help to convert code below from vb.net to C#? I appreciate your help in advance..

  Public Function GetBiosSerialNumber() As String
        Dim OutputString As String = String.Empty
        Using Process As New Process
            AddHandler Process.OutputDataReceived, Sub(sender As Object, e As DataReceivedEventArgs)
                                                       OutputString = OutputString & e.Data & vbCrLf
                                                   End Sub
            With Process.StartInfo
                .FileName = "cmd"
                .UseShellExecute = False
                .CreateNoWindow = True
                .RedirectStandardInput = True
                .RedirectStandardOutput = True
                .RedirectStandardError = True
            End With
            With Process
                .Start()
                .BeginOutputReadLine()
            End With
            Using InputStream As System.IO.StreamWriter = Process.StandardInput
                With InputStream
                    .AutoFlush = True
                    .Write("wmic bios get serialnumber" & vbCrLf)
                End With
            End Using
            Do
                Application.DoEvents()
            Loop Until Process.HasExited
        End Using
        Return Replace(OutputString.Split(CChar(vbCrLf)).ToList(6).Substring(1), " ", "")
    End Function

Answers (2)