Пример #1
0
 public UpdatedExeNotifier(string fileToWatch) : base(fileToWatch)
 {
     if (!CurrentExe.GetFullPath().IsInTempDir())
     {
         RelaunchInTemp();
     }
 }
Пример #2
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;
        }
Пример #3
0
        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));
     }
 }
Пример #5
0
        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);
            }
        }
Пример #6
0
        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();
        }
Пример #7
0
        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;
        }
Пример #8
0
 public static void RelaunchApp()
 {
     Process.Start(GetFullPath());
     CurrentExe.Shutdown();
 }
 public ClonedCopyExeUpdater(IThrottledFileWatcher throttledFileWatcher)
 {
     ClonedCopy           = CurrentExe.GetFullPath();
     _watchr              = throttledFileWatcher;
     _watchr.FileChanged += OnMasterCopyChanged;
 }