title: Taking ownership of a file or folder
body: <p>Before I pull out the rest of my hair I'd like to get some input on this.<br>
  I'm trying to take ownership of a folder. I'm running the program as administrator of course and I do have rights to take ownership since I can change the owner in explorer.  </p>
  
  <p>I can however change the owner if either administrator or my account owns it, and I can change permissions if I already have ownership.<br>
  If I try to  give myself ownership of a file, lets say owned by SYSTEM, then I get an unauthorizedexception.  </p>
  
  <p>I've tried some different things with the accesscontrol methods but nothing works, this latest method I think is directly by the book.</p>
  
  <pre><code>        private static void makePerm(string file, NTAccount account)
      {
          FileInfo finfo = new FileInfo(file);
          FileSecurity fsecurity = finfo.GetAccessControl();
          //also tried it like this //fsecurity.ResetAccessRule(new FileSystemAccessRule(string.Format(@"{0}\{1}", Environment.UserDomainName.ToString(), Environment.UserDomainName.ToString()), FileSystemRights.FullControl, AccessControlType.Allow));
          fsecurity.SetOwner(account);
          finfo.SetAccessControl(fsecurity);
      }
  </code></pre>
  
  <p>I'm trying this on Windows 7 btw.<br>
  What am I missing here?</p>