-3

how to retrieve the details who are connected to Shared folder Sessions.

Computer Management->Shared Folders->Sessions ??

I have tried retrieving shared folder details using ManagementScope Class , but unable to get the list of sessions connected to the shared folder ..

i am unable to get the details of the sessions which are present in the network computer

Naveen
  • 21
  • 7

1 Answers1

0

You can use the command "Icacls.exe" to get a list of user that are accessing a folder. In C#, you can do it like:

// Start a process and with the folder path as parameter
string folder = @"N:\Documents\Files\folderName";
ProcessStartInfo oInfo = new ProcessStartInfo();
oInfo.FileName = "Icacls.exe";
oInfo.Arguments = folder;
oInfo.RedirectStandardOutput = true;
oInfo.UseShellExecute = false;
Process oProcess = new Process();
oProcess.StartInfo = oInfo;
oProcess.Start();

// Redirect the result in a string
string result = oProcess.StandardOutput.ReadToEnd();
Console.WriteLine(result);        
Console.Read();

// Do some stuff with the string
Vincent L.
  • 46
  • 6
  • The Enumerating Network Sessions link which has been provided is not working for the remote computer . The error returns in 53-BADNETPATH – Naveen Aug 12 '16 at 09:12