Skip to content

Commit 73a8f9b

Browse files
roketworksfgreinacher
authored andcommitted
Added HResult value for ERROR_SHARING_VIOLATION to File in use exception
1 parent 6974273 commit 73a8f9b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

System.IO.Abstractions.TestingHelpers/CommonExceptions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace System.IO.Abstractions.TestingHelpers
44
{
55
internal static class CommonExceptions
66
{
7+
private const int _fileLockHResult = unchecked((int) 0x80070020);
8+
79
public static FileNotFoundException FileNotFound(string path) =>
810
new FileNotFoundException(
911
string.Format(
@@ -57,7 +59,7 @@ public static Exception InvalidUncPath(string paramName) =>
5759

5860
public static IOException ProcessCannotAccessFileInUse(string paramName = null) =>
5961
paramName != null
60-
? new IOException(string.Format(StringResources.Manager.GetString("PROCESS_CANNOT_ACCESS_FILE_IN_USE_WITH_FILENAME"), paramName))
61-
: new IOException(StringResources.Manager.GetString("PROCESS_CANNOT_ACCESS_FILE_IN_USE"));
62+
? new IOException(string.Format(StringResources.Manager.GetString("PROCESS_CANNOT_ACCESS_FILE_IN_USE_WITH_FILENAME"), paramName), _fileLockHResult)
63+
: new IOException(StringResources.Manager.GetString("PROCESS_CANNOT_ACCESS_FILE_IN_USE"), _fileLockHResult);
6264
}
6365
}

0 commit comments

Comments
 (0)