public string ReadRfidCard(byte COMPort=0) { if (COMPort == 0) COMPort = 0x05; string Uid=""; string CType=""; try { RFIDAPI rfidApi = new RFIDAPI(); rfidApi.RFID_OpenReader(COMPort); rfidApi.RFID_OpenCard(out Uid, out CType); rfidApi.RFID_CloseCard(); rfidApi.RFID_CloseReader(0x05); } catch(Exception ex) { Uid = "error"; } if (String.IsNullOrWhiteSpace(Uid)) Uid = "none"; if (String.IsNullOrWhiteSpace(CType)) CType = "none"; return Uid; }