vrijdag 10 december 2010

C# - easily get the message of a windows error code

I've seen a lot of posts online of people asking how to get the error message associated with a Windows error code. I've also seen a lot of posts online of people proposing some horribly difficult solution. So here's a nice and simple one I happened to stumble upon:
string win32ErrorMessage = new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()).Message;

Geen opmerkingen:

Een reactie posten