如何在c#中获取连接到共享文件夹会话的用户列表

本文关键字:文件夹 共享文件 会话 列表 用户 共享 连接 获取 | 更新日期: 2023-09-27 18:02:05

如何检索连接到共享文件夹会话的详细信息

计算机管理->共享文件夹->会话??

我已经尝试使用ManagementScope类检索共享文件夹的详细信息,但无法获得连接到共享文件夹的会话列表。

我无法获得网络计算机中存在的会话的详细信息

如何在c#中获取连接到共享文件夹会话的用户列表

您可以使用命令"Icacls.exe"来获取正在访问文件夹的用户列表。在c#中,你可以这样做:

// 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