开发者

API function to find username of shared files or folders on network in c# or vb.net

With the help of NetFileEnum or Openfiles.exe of system32, we can get the username who has opened the shared files. Is there any API function or any exe files 开发者_Python百科in any programming language like c#, vb.net, visual c++ to find out who is the user to create, rename, or delete shared files or folders on the network?


Try this one out, it will give you access rights information on a file

string fileName = @"C:\Text.txt";

FileSecurity oFSec = File.GetAccessControl(fileName);
AuthorizationRuleCollection oARC = oFSec.GetAccessRules(true, true, typeof(NTAccount));

foreach (FileSystemAccessRule oFSAR in oARC)
{
    Console.WriteLine("User : " + oFSAR.IdentityReference.Value);
    Console.WriteLine("Access Control Type : " + oFSAR.AccessControlType.ToString());
    Console.WriteLine("File System Rights : " + oFSAR.FileSystemRights.ToString());
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜