Reputation: 3
I am trying to make a game launcher that should be able to patch the game file if the game file and the other game file on the web server don't match.
To compare the files I could compare the size of both of them but I need a way to cast a file from web to a FileStream instance.
Any ideas?
Upvotes: 0
Views: 311
Reputation: 27914
Clearly it is not practical to download the file from the web server every time you want to check if your local file is the same as the one online. Thats what checksum are for.
All you have to do is hash your local file and compare the checksum with the one from the server, that is provided somewhere along with the file itself, like file.sha1
containing the 160-bits SHA-1 hash of the file.
However this operation is usually done only when you want to perform a full integrity check of your local files. Usually, updates and such are done simply by keeping track of the game version. Have a file containing a list of all updates, their respective versions and the package name that should be downloaded to update to that version. Provide update packages containing the modified files for each update you release, so the game launcher can download and install them in order to keep the game up to date.
Upvotes: 0