public static List <AutoUpdaterMessage> Update() { List <AutoUpdaterMessage> result = null; string logfile = $"{DateTime.Now.Ticks}_{Path.GetFileNameWithoutExtension( Path.GetTempFileName() )}.log"; string logPath = Path.Combine(CurrentPath, logfile); ProcessStartInfo psi = new ProcessStartInfo() { FileName = Path.Combine(CurrentPath, @"Synapse.Server.AutoUpdater.exe"), WorkingDirectory = CurrentPath, Arguments = $"shadowcopy {logPath}", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }; try { result = AutoUpdaterMessage.LoadOneMessage(DateTime.Now, $"Starting update, logging to [{logfile}]."); Process p = Process.Start(psi); } catch (Exception ex) { result = AutoUpdaterMessage.LoadOneMessage(DateTime.Now, ex.Message); } return(result); }
public static List <AutoUpdaterMessage> FetchLog(string logfile = null) { if (string.IsNullOrWhiteSpace(logfile)) { DirectoryInfo directory = new DirectoryInfo(CurrentPath); logfile = directory.GetFiles("*.log", SearchOption.TopDirectoryOnly) .OrderByDescending(f => f.LastWriteTime) .First().Name; } string logPath = Path.Combine(CurrentPath, logfile); if (File.Exists(logPath)) { return(AutoUpdaterMessage.LoadFile(logPath)); } else { return(AutoUpdaterMessage.LoadOneMessage(DateTime.Now, $"Could not find logfile {logfile}")); } }