VB.net Get username of locked file in network location

et3ishak a 1 Reputation point
2021-06-10T13:32:30.503+00:00

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 API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,429 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,126 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 81,831 Reputation points
    2021-06-10T14:26:18.837+00:00

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

    0 comments No comments

  2. Xiaopo Yang - MSFT 11,501 Reputation points Microsoft Vendor
    2021-06-29T06:42:55.367+00:00

    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.

    0 comments No comments