How do I look up the proper Windows System Error Code to use in my application?

前端 未结 4 1047
遇见更好的自我
遇见更好的自我 2020-12-21 05:57

I am writing a C# .NET 2.0 application wherein when a message is expected to be received via the SerialPort. If the frame is not received (i.e. times out) or i

4条回答
  •  抹茶落季
    2020-12-21 06:41

    Unfortunately the above didn't work for me, however this worked perfectly for me, pasting the whole code so it can be copy pasted directly in C#

    public static class WinErrors
    {
        /// 
        /// Gets a user friendly string message for a system error code
        /// 
        /// System error code
        /// Error string
        public static string GetSystemMessage(uint errorCode)
        {
            var exception = new Win32Exception((int)errorCode);
            return exception.Message;
        }
    }
    

提交回复
热议问题