Question: For some reason, when I try to check a file against FileAttributes.Normal, it seems like almost none of my files are showing up in my search. According to the API, that's because some other attributes are set. That's OK, I'll just need to search by what I *don't* want. This is where the problem comes in.

I'm incredibly rusty on my bitwise operator math, especially when it comes to checking multiple things at once. I'm trying to figure out how to get an if statement to return false if any of a certain number of file attributes are present (i.e. NONE of the specified attributes can be found if it wants to pass through my search). Here's what I've written so far:

```
if ((File.GetAttributes(stringFileName) &
   (FileAttributes.System | FileAttributes.Hidden | FileAttributes.Archive |
    FileAttributes.Encrypted | FileAttributes.Temporary)) == 0)

```

I'm thinking that it should take the conglomerate of all the different attributes and compare them to the original attributes of the file. If any match is found, the entire thing is rendered zero. However, this doesn't seem to be working as intended. Should I have used a different operator than the bitwise and (&)?

Thanks!

**Update:**

It appears that it wasn't the bitmask logic that was the problem, but rather FileAttributes.Archive. For some reason my files were nearly all marked with this flag (perhaps indicating that they are destined for backup?). At least now I know, and knowing is half the battle. :)

Answer: 
What this is doing is giving you just those attributes that you selected.

```
if ((File.GetAttributes(stringFileName) &
    (FileAttributes.System | FileAttributes.Hidden | FileAttributes.Archive |
    FileAttributes.Encrypted | FileAttributes.Temporary)) != 0)

```

There, just swap the equality for an inequality. This way, if any of those attributes are present, the final result will be non-zero.
Your logic is backwards. If any match is found then the result of bitwise and (&) is non-zero.

**Examples:**

*A match:*
0101000 & 0100000 = 0100000 != 0

*No match:*
0101000 & 0010000 = 0000000