コード例 #1
0
        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;
        }
コード例 #2
0
 private static string MakeAbsolute(string filepath)
 {
     if (Path.IsPathRooted(filepath))
     {
         return(filepath);
     }
     else
     {
         return(Path.Combine(CurrentExe.GetDirectory(), filepath));
     }
 }
コード例 #3
0
        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));
        }
コード例 #4
0
 public ClonedCopyExeUpdater(IThrottledFileWatcher throttledFileWatcher)
 {
     ClonedCopy           = CurrentExe.GetFullPath();
     _watchr              = throttledFileWatcher;
     _watchr.FileChanged += OnMasterCopyChanged;
 }
コード例 #5
0
 public static void RelaunchApp()
 {
     Process.Start(GetFullPath());
     CurrentExe.Shutdown();
 }