diotalevi seems to have the right answer if all you want to do is compare files once. If on the other hand you want to determine which files have changed since the last check, you're better off either comparing timestamps, or if that isn't enough, storing MD5 hashes and using those to compare.