public static bool DownloadFromInternet(bool isCorrupted)
{
bool fileExists = File.Exists(Application.StartupPath + @"\Plugins\CTGP-7CourseNames.xml");
DialogResult res;
if (!isCorrupted)
{
res = MessageBox.Show("Download the most recent CTGP-7 course names?", "CTGP-7 Course Names", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
} else
{
res = MessageBox.Show("The CTGP-7 course names file doesn't exist or is corrupted.\nDownload the most recent version?", "CTGP-7 Course Names", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
if (res == DialogResult.Yes)
{
if (fileExists) File.Delete(Application.StartupPath + @"\Plugins\CTGP-7CourseNames.xml");
}
else return false;
System.Net.WebClient webClient = new System.Net.WebClient();
try
{
webClient.DownloadFile("https://raw.githubusercontent.com/mariohackandglitch/CTGP7EFEPlugin/master/CTGP-7CourseNames.xml", Application.StartupPath + @"\Plugins\CTGP-7CourseNames.xml");
} catch (Exception e)
{
MessageBox.Show("Failed to download data:\n\n" + e.Message, "CTGP-7 Course Names", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
MessageBox.Show("Data downloaded successfully!" + (isCorrupted ? "" : "\nPlease restart application for changes to take effect."), "CTGP-7 Course Names", MessageBoxButtons.OK, MessageBoxIcon.Information);
return true;
}