That's pretty simple in .Net. You need to add these library:
using System.IO.Ports;
To open/close a port:
serialport.Open();
serialport.Close();
but you need to be carefull not the open an open one. You need to check if it's open or not with:
serialport.IsOpen();
Then you can use SerialPort class and make necassery adjustments like Port name, baudrate, parity, handshake...
seriPort.PortName = ....;
serialPort.BaudRate = ...;
serialPort.Parity = Parity.None;
serialPort.Handshake = Handshake.RequestToSend;
Also, you can get all the serialPort(including virtual ones) names using this little code:
serialport.GetPortNames();
Have Fun :)