title: Get the owner of a file in VB.NET
body: <p>I have encountered a error in VB.NET when I want to get the owner of a file.</p>
  
  <p>This is my code.</p>
  
  <pre><code>Imports System.Security.AccessControl
  Imports System.Security.Principal
  Imports System.IO
  Dim fi As FileInfo = New FileInfo("X:\Temp\aa.txt")
  Dim fs As FileSecurity = fi.GetAccessControl
  Dim myuser As IdentityReference = fs.GetOwner(GetType(NTAccount))
  Dim username = myuser.Value.ToString
  </code></pre>
  
  <p>and I got error:</p>
  
  <pre><code>System.Security.Principal.IdentityNotMappedException was caught
  HResult=-2146233087
  Message=Unable to translate some or all of the recognition references。
  Source=mscorlib
  StackTrace:
   System.Security.Principal.SecurityIdentifier.Translate(IdentityReferenceCollection sourceSids, Type targetType, Boolean forceSuccess)
         in System.Security.Principal.SecurityIdentifier.Translate(Type targetType)
         in System.Security.AccessControl.ObjectSecurity.GetOwner(Type targetType)
         in Ts2.From1.Button1_Click(Object sender, EventArgs e) 於 D:\Ts3\Ts1\Form1.vb: row 292
    InnerException: 
  </code></pre>