I am currently using the .NET 7.0 framework in Visual Studio. I am trying to transfer a file over a serial port however I am having some trouble. I am just wondering if there is a NuGet package or something I must do in order to enable me to transfer said file. I have attached below the code I have tried, let me know if I have made any mistakes.
In .NET4.8 there is a SerialPort object however it doesn't apper in any later versions.
DOES ANYBODY KNOW IF THIS OBJECT IS OBTAINABLE IN .NET7.0
SerialPort myPort = new SerialPort("COM3", 19200, Parity.None, 8, StopBits.One);
myPort.PortName = "COM3";
myPort.BaudRate = 19200;
myPort.Parity = Parity.None;
myPort.DataBits = 8;
myPort.StopBits = StopBits.One;
myPort.Open();
Data = FileBuild.SelectMany(s =>
System.Text.Encoding.UTF8.GetBytes(s + Environment.NewLine)).ToArray();
// Data = FileBuild.SelectMany(BitConverter.GetBytes).ToArray();
myPort.Write(Data, 0, Data.Length);
myPort.Close();
The error message provided was:
System.IO.FileNotFoundException: 'Could not find file 'COM3'.'