You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To find the `Process` objects that are locking one or more files, you can invoke the `FindLockingProcesses` (or `FindLockingProcessesAsync`) method with multiple `path` parameters:
To unlock a `FileLocker`, you can execute the `Unlock` method:
@@ -37,12 +57,71 @@ DeadLock.Unlock(locker);
37
57
38
58
You can also run the code asynchronously by running the `UnlockAsync` method:
39
59
```c#
40
-
DeadLock.UnlockAsync(locker);
60
+
awaitDeadLock.UnlockAsync(locker);
61
+
```
62
+
63
+
To unlock more than one `FileLocker` object, you can invoke the `Unlock` (or `UnlockAsync`) method with multiple `FileLocker` parameters:
64
+
```c#
65
+
Unlock(fileLockerA, fileLockerB, fileLockerC);
41
66
```
42
67
68
+
Alternatively, if you only want to unlock a file and you are not interested in using the `FileLocker` objects, you can do so by providing any of the `Unlock` or `UnlockAsync` methods with one or more `string` variables that represent the path or paths of the file(s) that should be unlocked:
69
+
```c#
70
+
// Unlock a single path
71
+
stringpath=@"C:\...\file.txt";
72
+
Unlock(path);
73
+
74
+
// Unlock multiple files
75
+
Unlock(path1, path2, path3);
76
+
77
+
// Asynchronously unlock one or more files
78
+
awaitUnlockAsync(path);
79
+
awaitUnlockAsync(path1, path2, path3);
80
+
```
81
+
82
+
### `FileLocker`
83
+
84
+
The `FileLocker` object contains a `List` of `System.Diagnostics.Process` objects that are locking a file.
85
+
You can retrieve the `List` of `Process` objects by retrieving the respective property:
86
+
```c#
87
+
List<Process>processes=fileLocker.Lockers;
88
+
```
89
+
90
+
To retrieve the path of the file that the `Process` objects are locking, you can make use of the `Path` property:
91
+
```c#
92
+
stringpath=fileLocker.Path;
93
+
```
94
+
95
+
### Error handling
96
+
97
+
deadlock-dotnet-sdk has three specific `Exception` types that might occur when trying to find the `Process` objects that are locking a file.
98
+
99
+
*`RegisterResourceException`
100
+
*`RmListException`
101
+
*`StartSessionException`
102
+
103
+
In case you want more detailed error messages, it is recommended that you call the `Marshal.GetLastWin32Error` method as soon as one of these `Exception` types occur:
This error occurs when the system goes out of memory, when a specific time-out occurs or if an invalid handle is detected. You can find more information about this exception here:
This error occurs when the system goes out of memory, when a specific time-out occurs or if an invalid handle is detected. You can find more information about this exception here:
This error occurs when the system goes out of memory, when a specific time-out occurs or if an invalid handle is detected. You can find more information about this exception here:
0 commit comments