mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-17 20:43:46 +02:00
Moved NTFileSystemAdapter to SMBLibrary.Adapters
This commit is contained in:
parent
f1c34e9b14
commit
7a31435531
16 changed files with 147 additions and 43 deletions
31
SMBLibrary.Adapters/NTFileSystemAdapter/IOExceptionHelper.cs
Normal file
31
SMBLibrary.Adapters/NTFileSystemAdapter/IOExceptionHelper.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* Copyright (C) 2014-2020 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
*
|
||||
* You can redistribute this program and/or modify it under the terms of
|
||||
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.Adapters
|
||||
{
|
||||
public class IOExceptionHelper
|
||||
{
|
||||
public static ushort GetWin32ErrorCode(IOException ex)
|
||||
{
|
||||
int hResult = GetExceptionHResult(ex);
|
||||
// The Win32 error code is stored in the 16 first bits of the value
|
||||
return (ushort)(hResult & 0x0000FFFF);
|
||||
}
|
||||
|
||||
public static int GetExceptionHResult(IOException ex)
|
||||
{
|
||||
PropertyInfo hResult = ex.GetType().GetProperty("HResult", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
return (int)hResult.GetValue(ex, null);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue