public UpdatedExeNotifier(string fileToWatch) : base(fileToWatch) { if (!CurrentExe.GetFullPath().IsInTempDir()) { RelaunchInTemp(); } }
public void StartWatching(string filepath) { if (_fsWatchr != null) { return; } if (!File.Exists(filepath)) { throw new FileNotFoundException($"File not found:{L.f}{filepath}"); } var dir = Path.IsPathRooted(filepath) ? Path.GetDirectoryName(filepath) : CurrentExe.GetDirectory(); var nme = Path.GetFileName(filepath); TargetFile = Path.Combine(dir, nme); _fsWatchr = new FileSystemWatcher(dir, nme); _fsWatchr.NotifyFilter = NotifyFilters.LastWrite; _fsWatchr.Changed += new FileSystemEventHandler(OnLdbChanged); _fsWatchr.EnableRaisingEvents = true; }
public static void RelaunchApp() { //Process.Start(GetFullPath()); var orig = Environment.GetCommandLineArgs(); var args = orig.QuotifyCommandLineArgs(); Process.Start(orig[0], args); CurrentExe.Shutdown(); }
public static string MakeAbsolute(this string filePath) { if (Path.IsPathRooted(filePath)) { return(filePath); } else { return(Path.Combine(CurrentExe.GetDirectory(), filePath)); } }
private static void CopyCfgToTemp(string tmpExe) { var exeNow = CurrentExe.GetFullPath(); var cfgNow = exeNow + ".config"; var tmpCfg = tmpExe + ".config"; if (File.Exists(cfgNow)) { File.Copy(cfgNow, tmpCfg, true); } }
private void RelaunchInTemp() { if (WatchedFile.IsBlank()) { return; } var exeNow = CurrentExe.GetFullPath(); var cfgNow = exeNow + ".config"; var tmpExe = WatchedFile.MakeTempCopy(".exe"); var tmpCfg = tmpExe + ".config"; if (File.Exists(cfgNow)) { File.Copy(cfgNow, tmpCfg, true); } Process.Start(tmpExe, GetCommandLineArgs()); Application.Current.Shutdown(); }
public void StartWatching(string folderPath) { if (_fsWatchr != null) { return; } if (!Directory.Exists(folderPath)) { throw new DirectoryNotFoundException($"Directory not found:{L.f}{folderPath}"); } TargetFolder = Path.IsPathRooted(folderPath) ? folderPath : Path.Combine(CurrentExe.GetDirectory(), folderPath); _fsWatchr = new FileSystemWatcher(TargetFolder); _fsWatchr.NotifyFilter = NotifyFilters.LastWrite; _fsWatchr.Changed += new FileSystemEventHandler(OnLdbChanged); _fsWatchr.EnableRaisingEvents = true; }
public static void RelaunchApp() { Process.Start(GetFullPath()); CurrentExe.Shutdown(); }
public ClonedCopyExeUpdater(IThrottledFileWatcher throttledFileWatcher) { ClonedCopy = CurrentExe.GetFullPath(); _watchr = throttledFileWatcher; _watchr.FileChanged += OnMasterCopyChanged; }