Ejemplo n.º 1
0
        /// <summary>
        /// Check if an update is available and download it and the installer if this is the case
        /// </summary>
        /// <param name="user">github user name</param>
        /// <param name="repository">github repository name</param>
        /// <param name="currentVersion">Current version of application.</param>
        /// <param name="tempDir">The directory were temporary files should be stored</param>
        /// <returns><see langword="true"/> if a new version is available, otherwise <see langword="false"/></returns>
        public async Task <bool> CheckDownloadNewVersionAsync(string user, string repository
                                                              , Version currentVersion, string tempDir)
        {
            return(await Task.Run(async() =>
            {
                Directory.CreateDirectory(tempDir);
                updateArchiveFileName = Path.Combine(tempDir, "update.zip");
                Available = await UpdateTools.CheckDownloadNewVersionAsync(
                    user, repository, currentVersion, updateArchiveFileName);

                installerName = await UpdateTools.DownloadExtractInstallerToAsync(tempDir);
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Available)));
                return Available;
            }));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Install the update. <see cref="CheckDownloadNewVersionAsync(string, string, Version, string)"/> has to be called otherwise no update can be available.
 /// If you update the currently executing program. Do not wait for the install to finish,
 /// but close the program.
 /// </summary>
 public Process StartInstall(string destinationDir)
 {
     return(UpdateTools.StartInstall(installerName, updateArchiveFileName, destinationDir));
 }