I'm writting a SerialPort program. Sometimes when I want to open the SerialPort, an UnauthorizedAccessException is thrown :access to COM1 is denied. This is beause another program( which is written by someone else and I don't have its soucecode ) is using COM1, and that program doesn't close COM1 when it exits.
I want to ask 2 questions:
- How to close COM1 with my code (especially C# code) when it is used by another program?
- If I cannot close COM1 with C# code, how can I close or free COM1 in Windows OS?
Thanks.