[C#] Detecting changes to files in folders on two machines

Started by
2 comments, last by rip-off 13 years, 4 months ago
Hey all,

The game I am writing uses a client/server architecture, and I would like to add a check that the server initiates to see if some key files on the client's machine are what they should be. I would appreciate any pointers as to the most efficient way of doing this - at present I have managed to arrange the data so that all files within a couple of folders need checking, and I was also wondering if there is a more efficient way of doing this rather than checking each file individually.

Thanks in advance,

Wibbs
Advertisement
The typical method would be to hash the contents of each critical file and compare hashes between the server and client; this avoids the need to do any hefty transfers of data for the actual comparison. It may slightly increase load times, but I'm not sure offhand of a good way to avoid that.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Thanks,

That's the conclusion I'd come to, but wanted to check whether there was a way the contents of a folder could be treated as a single entity rather than having to hash each file seperately.

Wibbs
Well, for network efficiency you could just send the hash of the concatenation of the different file hashes. Whether this is useful depends on the number of files involved. I don't believe there is a way to avoid reading the files though.

One idea might be to pack all these critical files in a compressed archive. That way you get faster reads, less data and less chance the player will interfere with the files.

Also don't depend on this for anti-cheating, it is easy to modify the executable to send the correct hashes, or even to change the data on the wire. It can only work as a consistency check, e.g. that both players have the same version of a map or a mod.

This topic is closed to new replies.

Advertisement