using PWAppUpdater.FTP; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; namespace PWAppUpdater { class Updater { public static void Update(string installPath, string practiceConfigLocation = "", string tempPath = "") { try { if (tempPath == "") { tempPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); tempPath = Path.Combine(tempPath, "PWAPP\\Temp"); } if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } FTP.FTPManager ftpManager = new FTPManager("ftp://waws-prod-blu-109.ftp.azurewebsites.windows.net/", "patientweb\\$patientweb", "vHBnkgxPDS4Q410eehaFlXb8DH67QW50m9Rsxf1omXyYWRDgYioWJL63Tagp"); ftpManager.DownloadFile("pwapp/current/Release.zip", tempPath); if (Directory.Exists(installPath)) { Directory.Delete(installPath, true); } Directory.CreateDirectory(installPath); Zip.ZipManager.UnZip(tempPath, installPath, true); } catch (UnauthorizedAccessException) { MessageBox.Show("Updater does not have sufficent permissions to perform update. Please run with administrator privilages to continue."); } } } class CouldNotFindInstallPathException : Exception { } }