Exemple #1
0
        internal async Task <bool> UpdateAssemblies()
        {
            //Set up temp folder
            tempPath = Path.Combine(Path.GetTempPath(), "IfTextEditor");
            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }

            var tempInfo = new DirectoryInfo(tempPath);

            foreach (FileInfo file in tempInfo.GetFiles())
            {
                file.Delete();
            }

            //For each new update, download to tmp folder
            foreach (UpdateContainer.UpdateInfo update in updates)
            {
                if (!update.UpdateAvailable)
                {
                    continue;
                }

                controller.UpdateLabel("Updating " + update.AssemblyName);
                string filePath = Path.Combine(tempPath, update.AssemblyName);
                await DownloadFile(update.DownloadUri, Path.Combine(tempPath, filePath));

                controller.UpdateLabel("Verifying " + update.AssemblyName);
                if (!VerifyDownloadIntegrity(filePath, update))
                {
                    return(false);
                }
            }

            return(true);
        }