diff --git a/DS4Windows/DS4Forms/WelcomeDialog.xaml.cs b/DS4Windows/DS4Forms/WelcomeDialog.xaml.cs index 67c060e..8d4f092 100644 --- a/DS4Windows/DS4Forms/WelcomeDialog.xaml.cs +++ b/DS4Windows/DS4Forms/WelcomeDialog.xaml.cs @@ -16,6 +16,7 @@ namespace DS4WinWPF.DS4Forms private const string InstallerDL = "https://github.com/ViGEm/ViGEmBus/releases/download/v1.16.112/ViGEmBus_Setup_1.16.115.exe"; private const string InstFileName = "ViGEmBus_Setup_1.16.115.exe"; + private string tempInstFileName; Process monitorProc; NonFormTimer monitorTimer; @@ -30,6 +31,8 @@ namespace DS4WinWPF.DS4Forms } InitializeComponent(); + + tempInstFileName = DS4Windows.Global.exedirpath + $"\\{InstFileName}.tmp"; } private void FinishedBtn_Click(object sender, RoutedEventArgs e) @@ -44,6 +47,11 @@ namespace DS4WinWPF.DS4Forms File.Delete(DS4Windows.Global.exedirpath + $"\\{InstFileName}"); } + if (File.Exists(tempInstFileName)) + { + File.Delete(tempInstFileName); + } + ViGEmDownloadLaunch(); /*WebClient wb = new WebClient(); @@ -67,9 +75,17 @@ namespace DS4WinWPF.DS4Forms }); string filename = DS4Windows.Global.exedirpath + $"\\{InstFileName}"; - using (var downloadStream = new FileStream(filename, FileMode.CreateNew)) + bool success = false; + using (var downloadStream = new FileStream(tempInstFileName, FileMode.CreateNew)) { - HttpResponseMessage response = await App.requestClient.GetAsync(InstallerDL, downloadStream, progress); + HttpResponseMessage response = await App.requestClient.GetAsync(InstallerDL, + downloadStream, progress); + success = response.IsSuccessStatusCode; + } + + if (success) + { + File.Move(tempInstFileName, filename); } if (File.Exists(DS4Windows.Global.exedirpath + $"\\{InstFileName}"))