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;
        }
 private static string MakeAbsolute(string filepath)
 {
     if (Path.IsPathRooted(filepath))
     {
         return(filepath);
     }
     else
     {
         return(Path.Combine(CurrentExe.GetDirectory(), filepath));
     }
 }
        private static bool TryFindFile(string filepath, out string absolutePath)
        {
            absolutePath = null;
            if (filepath.IsBlank())
            {
                return(false);
            }

            if (File.Exists(filepath))
            {
                absolutePath = filepath;
                return(true);
            }

            var exeDir = CurrentExe.GetDirectory();

            absolutePath = Path.Combine(exeDir, filepath);
            return(File.Exists(absolutePath));
        }
Exemple #4
0
 public ClonedCopyExeUpdater(IThrottledFileWatcher throttledFileWatcher)
 {
     ClonedCopy           = CurrentExe.GetFullPath();
     _watchr              = throttledFileWatcher;
     _watchr.FileChanged += OnMasterCopyChanged;
 }
 public static void RelaunchApp()
 {
     Process.Start(GetFullPath());
     CurrentExe.Shutdown();
 }