public void CheckUpdate() { if (isChecking == true) { return; } isChecking = true; ConfigFile updateCfg = new ConfigFile(workPath + "/" + updateConfigName); localVersion = updateCfg.ReadValue("AppInfo", "AppVersion"); WebClient dlClient = new WebClient(); dlClient.DownloadFileCompleted += new AsyncCompletedEventHandler(OnCheckUpdateEnd); try { dlClient.DownloadFileAsync(new Uri(serverConfigFileUrl), tmpFileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } return; }
public void OnCheckUpdateEnd(object sender, AsyncCompletedEventArgs e) { ConfigFile serverCfg = new ConfigFile(workPath + "/" + tmpFileName); serverVersion = serverCfg.ReadValue("AppInfo", "AppVersion"); if (localVersion == serverVersion) { isChecking = false; if (File.Exists(tmpFileName)) { File.Delete(tmpFileName); } MessageBox.Show("Your App is the latest version"); return; } WebClient dlClient = new WebClient(); string patchUrl = serverCfg.ReadValue("PatchName", "Url"); dlClient.DownloadFileCompleted += new AsyncCompletedEventHandler(OnDownloadEnd); dlClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(OnDownloadChanged); if (File.Exists(patchFileName)) { File.Delete(patchFileName); } try { dlClient.DownloadFileAsync(new Uri(patchUrl), patchFileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (File.Exists(tmpFileName)) { File.Delete(tmpFileName); } updWin.Show(); }
public Update() { ConfigFile updateCfg = new ConfigFile(workPath + "/" + updateConfigName); serverConfigFileUrl = updateCfg.ReadValue("ServerInfo", "ConfigFileUrl"); if (File.Exists("old_")) { File.Delete("old_"); } }
public string ReadWindowTitle() { ConfigFile cfg = new ConfigFile(configFileName); return(cfg.ReadValue("Key", "WindowTitle")); }
public string ReadMacroKey() { ConfigFile cfg = new ConfigFile(configFileName); return(cfg.ReadValue("Key", "MacroKey")); }