0

I have my files on Github and whenever the game updates, I only translate the files. Then I write in the change log in the changelog what has been changed ..

How can I do it with C # that I have updated?

I just want to read out that the Changelog.txt was changed and the people would then get a message in the program new update.

I have a button where people click on it to download.

I know that I have to find out the hash of the file somehow but have no idea how to do it.

AndyDE
  • 1
  • 3

1 Answers1

0

You can compute a md5 for the current and the last changelog (see here). Is the old changelog beside the application on local pc or are both at github? Also have a look at this Question.

Maybe this simple example can help:

byte[] newChecksum;
byte[] oldChecksum;

using (var md5 = MD5.Create())
{
  // Changelog file on local PC
  using (var stream = File.OpenRead("Changelog.txt"))
  {
    oldChecksum = md5.ComputeHash(stream);
  }
}

string githubRawURl = "https://raw.githubusercontent.com/YOUR_USERNAME/YOUR_REPO/master/Changelog.txt";
            
using (WebClient client = new WebClient())
{
  using (var md5 = MD5.Create())
  {
    // Changelog file on Github master branch
    using (var stream = client.OpenRead(githubRawURl))
    {
      newChecksum = md5.ComputeHash(stream);
    }
 }
}

if (!oldChecksum.SequenceEqual(newChecksum))
{
    MessageBox.Show("There is an Update");
}
else
{
    MessageBox.Show("There is no Update");
}

I´m not sure if this is exactly what you are looking for?!

sunriax
  • 352
  • 6