// Get the file info
String fileName = @"C:Users ingwangDesktopprocmon.exe";
FileInfo info = new FileInfo( fileName );
Console.WriteLine( info.Length );
FileSecurity security = info.GetAccessControl( AccessControlActions.View ); 
// Owner SID:
Type owenerType = Type.GetType("System.Security.Principal.SecurityIdentifier");
IdentityReference ownerId = info.GetAccessControl().GetOwner(owenerType);
Console.WriteLine("File Owner SID is : {0}", ownerId.Value); 
// Account Name:
NTAccount account = ( NTAccount )( ownerId.Translate( Type.GetType( "System.Security.Principal.NTAccount" ) ) );
Console.WriteLine( account.Value );
本文介绍了一种使用C#获取指定文件的长度、所有者SID及账户名称的方法,并通过示例代码展示了如何实现这些功能。
2053

被折叠的 条评论
为什么被折叠?



