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!
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!
openfiles.exe uses NtQuerySystemInformation (mainly with SystemExtendedHandleInformation),
so it is complicated and it is easier to parse the output of openfiles.exe...
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.
6 people are following this question.