title: Comparing 2 FileAttributes must always return true in C#
body: <p>I recently got some great help here on stackoverflow. One of the answers puzzled me somewhat and I didn't feel it was appropriate to get an explanation due to the limitations of the comments box.</p>
  
  <p>Please review the code below.</p>
  
  <pre><code>if ((File.GetAttributes(fileName) &amp; FileAttributes.Archive) == FileAttributes.Archive)
  {
      // Archive file.
  }
  </code></pre>
  
  <p>My question is why would you include the logic after the &amp; (see bold)<br>
      (File.GetAttributes(fileName) <strong>&amp; FileAttributes.Archive</strong>) == etc</p>
  
  <p>Surely FileAttributes.Archive == FileAttributes.Archive will always match?</p>
  
  <p>Does any one have an explanation to this (IMO it's probably a typo/mistake but I've assumed too many things before to only be corrected later on!)</p>
  
  <p>The second question is what does the tilde <code>~</code> do in this code:</p>
  
  <pre><code>File.SetAttributes(fileName, File.GetAttributes(fileName) &amp; ~FileAttributes.Archive);
  </code></pre>