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