private static String GetMessage(int errorCode) { StringBuilder sb = new StringBuilder(512); int result = Win32Native.FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, Win32Native.NULL, errorCode, 0, sb, sb.Capacity, Win32Native.NULL); if (result != 0) { // result is the # of characters copied to the StringBuilder on NT, // but on Win9x, it appears to be the number of MBCS bytes. // Just give up and return the String as-is... String s = sb.ToString(); return(s); } else { return(Environment.GetResourceString("IO_UnknownError", errorCode)); } }