From fe2353c11d474eb005e2ca17fd8bc52a8a344845 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 16 Nov 2015 07:31:43 +1100 Subject: [PATCH] Don't hardcode English error message, use hresult. Fixes crashing with multiple clients open on non-English systems. (Thanks imjonnyboy) --- ClassicalSharp/Game/ChatLog.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ClassicalSharp/Game/ChatLog.cs b/ClassicalSharp/Game/ChatLog.cs index 634400dc2..ff377894e 100644 --- a/ClassicalSharp/Game/ChatLog.cs +++ b/ClassicalSharp/Game/ChatLog.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; using ClassicalSharp.Commands; namespace ClassicalSharp { @@ -102,7 +103,9 @@ namespace ClassicalSharp { try { stream = File.Open( path, FileMode.Append, FileAccess.Write, FileShare.Read ); } catch( IOException ex ) { - if( !ex.Message.Contains( "because it is being used by another process" ) ) + int hresult = Marshal.GetHRForException(ex); + uint errorCode = (uint)hresult & 0xFFFF; + if( errorCode != 32 ) // ERROR_SHARING_VIOLATION throw; continue; }