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 string MakeAbsolute(this string filePath) { if (Path.IsPathRooted(filePath)) { return(filePath); } else { return(Path.Combine(CurrentExe.GetDirectory(), filePath)); } }
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; }