Recursive dir delete in updater copy script

This commit is contained in:
Travis Nickles 2020-04-12 03:39:24 -05:00
parent 1c320505c6
commit 98fea512a4
2 changed files with 6 additions and 4 deletions

View File

@ -205,7 +205,7 @@ namespace DS4Windows
w.WriteLine($"@mov /Y \"{tmpUpdaterPath}\" {Global.exedirpath}\\DS4Updater.exe"); w.WriteLine($"@mov /Y \"{tmpUpdaterPath}\" {Global.exedirpath}\\DS4Updater.exe");
if (deleteUpdatesDir) if (deleteUpdatesDir)
{ {
w.WriteLine($"@del {Global.exedirpath}\\Update Files\\DS4Windows\\DS4Updater.exe"); w.WriteLine($"@del /S {Global.exedirpath}\\Update Files\\DS4Windows");
} }
w.WriteLine("@DEL \"%~f0\""); // Attempt to delete myself without opening a time paradox. w.WriteLine("@DEL \"%~f0\""); // Attempt to delete myself without opening a time paradox.
w.Close(); w.Close();

View File

@ -242,9 +242,10 @@ Properties.Resources.DS4Update, MessageBoxButton.YesNo, MessageBoxImage.Question
private bool RunUpdaterCheck(bool launch) private bool RunUpdaterCheck(bool launch)
{ {
bool updaterExists = File.Exists(Global.exedirpath + "\\DS4Updater.exe"); string destPath = Global.exedirpath + "\\DS4Updater.exe";
bool updaterExists = File.Exists(destPath);
if (!updaterExists || if (!updaterExists ||
(FileVersionInfo.GetVersionInfo(Global.exedirpath + "\\DS4Updater.exe").FileVersion.CompareTo(MainWindowsViewModel.UPDATER_VERSION) != 0)) (FileVersionInfo.GetVersionInfo(destPath).FileVersion.CompareTo(MainWindowsViewModel.UPDATER_VERSION) != 0))
{ {
launch = false; launch = false;
Uri url2 = new Uri($"https://github.com/Ryochan7/DS4Updater/releases/download/v{MainWindowsViewModel.UPDATER_VERSION}/{mainWinVM.updaterExe}"); Uri url2 = new Uri($"https://github.com/Ryochan7/DS4Updater/releases/download/v{MainWindowsViewModel.UPDATER_VERSION}/{mainWinVM.updaterExe}");
@ -266,7 +267,8 @@ Properties.Resources.DS4Update, MessageBoxButton.YesNo, MessageBoxImage.Question
} }
else else
{ {
File.Move(filename, Global.exedirpath + "\\DS4Updater.exe"); File.Delete(destPath);
File.Move(filename, destPath);
} }
} }
} }