question

et3ishaka-5509 avatar image
0 Votes"
et3ishaka-5509 asked XiaopoYang-MSFT answered

VB.net Get username of locked file in network location

Hello I am attempting to find a way in .Net that gives the name of a user who has a file open in a network location. I prefer to use a .Net library and avoid wrapping openfiles.exe.

Any help is apprecited!

windows-apidotnet-runtime
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered

openfiles.exe uses NtQuerySystemInformation (mainly with SystemExtendedHandleInformation),
so it is complicated and it is easier to parse the output of openfiles.exe...



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

XiaopoYang-MSFT avatar image
0 Votes"
XiaopoYang-MSFT answered

We open file with FILE_READ_ATTRIBUTES and call NtQueryInformationFile with FileProcessIdsUsingFileInformation. on return we got FILE_PROCESS_IDS_USING_FILE_INFORMATION structure where list of ProcessId which hold this file. Here is a sample.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.