/// <summary> /// Method to call when the user starts notepad++, /// check if an update has been done since the last time notepad was closed /// </summary> public void CheckForUpdateDoneAndStartCheckingForUpdates() { var previousVersion = File.Exists(Config.UpdatePreviousVersion) ? Utils.ReadAllText(Config.UpdatePreviousVersion, Encoding.Default).Trim() : null; // compatibility with 3P v1.7.0 and older if (string.IsNullOrEmpty(previousVersion)) { var oldVersionLogPath = Path.Combine(Npp.ConfigDirectory, "version.log"); if (File.Exists(oldVersionLogPath)) { previousVersion = "1.7.0"; Utils.MoveFile(oldVersionLogPath, Config.UpdateVersionLog); } } // an update has been done if (!string.IsNullOrEmpty(previousVersion)) { // we didn't update to a newer version, something went wrong if (!AssemblyInfo.Version.IsHigherVersionThan(previousVersion)) { UserCommunication.Notify(@"<h2>I require your attention!</h2><br> The update didn't go as expected, the old plugin files have not been replaced by the new ones!<br> It is very likely because the updater didn't get the rights to write a file in your /plugins/ folder.<br> You will have to manually copy the new files to replace the existing files :<br><br> <b>MOVE (delete the source and replace the target)</b> all the files in this folder : <div>" + Config.UpdateReleaseUnzippedFolder.ToHtmlLink() + @"</div><br> <b>In this folder</b> (replacing the existing files) : <div>" + Path.GetDirectoryName(AssemblyInfo.Location).ToHtmlLink() + @"</div>", MessageImg.MsgUpdate, UpdatedSoftName + " updater", "Problem during the update!"); return; } Utils.DeleteFile(Config.UpdatePreviousVersion); // Special actions to take depending on the previous version? if (!string.IsNullOrEmpty(previousVersion)) { UpdateDoneFromVersion(previousVersion); } } // Show the version log if (File.Exists(Config.UpdateVersionLog)) { var versionLog = Utils.ReadAllText(Config.UpdateVersionLog, Encoding.Default); UserCommunication.NotifyUnique("UpdateVersionLog", "A new version of the software has been installed, congratulations!" + "<br><br><div>" + "log".ToHtmlLink("Click here to show what is new in this version") + "</div><br><div>" + "close".ToHtmlLink("Click here to stop showing this notification") + "</div>", MessageImg.MsgUpdate, UpdatedSoftName + " updater", "What is new in " + AssemblyInfo.Version + "?", args => { args.Handled = true; Utils.DeleteFile(Config.UpdateVersionLog); if (args.Link.Equals("log")) { UserCommunication.Message(versionLog.MdToHtml(), MessageImg.MsgUpdate, UpdatedSoftName + " updater", "Release notes from " + previousVersion + " to " + AssemblyInfo.Version, new List <string> { "ok" }, false); } UserCommunication.CloseUniqueNotif("UpdateVersionLog"); }); } StartCheckingForUpdate(); }