Is this a If statement bug?

You are overcomplicating things. Your FNames are clearly not equal if you enter the if branch (or don’t enter it when using ==). There is no question here whether Compare or == “work” (they do), if you expect your FNames to be equal but they aren’t, you simply have a bug somewhere in your code.