Don't hardcode English error message, use hresult. Fixes crashing with multiple clients open on non-English systems. (Thanks imjonnyboy)

This commit is contained in:
UnknownShadow200 2015-11-16 07:31:43 +11:00
parent cef936a5f4
commit fe2353c11d

View File

@ -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;
}