diff --git a/LegacyInstaller/MainWindow.xaml.cs b/LegacyInstaller/MainWindow.xaml.cs index 2e9201e..aebbcdb 100644 --- a/LegacyInstaller/MainWindow.xaml.cs +++ b/LegacyInstaller/MainWindow.xaml.cs @@ -262,14 +262,22 @@ private async Task InstallVersion(Version version) await _steamProcess.Downloader.DownloadDepot(version.ManifestId, FileSystemChanged); // Copy files - this.Dispatcher.Invoke((Action)delegate { installStateLabel.Content = "Copying..."; }); - Directory.CreateDirectory(SelectedVersionInstallDir); - var watcher = new FileSystemWatcher(SelectedVersionInstallDir); - watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size; - watcher.IncludeSubdirectories = true; - watcher.EnableRaisingEvents = true; - watcher.Changed += FileSystemChanged; - await Utilities.CopyDirectory(_steamProcess.Downloader.ContentAppDepotDir, SelectedVersionInstallDir); + try + { + this.Dispatcher.Invoke((Action)delegate { installStateLabel.Content = "Moving..."; }); + Utilities.MoveDirectory(_steamProcess.Downloader.ContentAppDepotDir, SelectedVersionInstallDir); + } + catch + { + this.Dispatcher.Invoke((Action)delegate { installStateLabel.Content = "Copying..."; }); + Directory.CreateDirectory(SelectedVersionInstallDir); + var watcher = new FileSystemWatcher(SelectedVersionInstallDir); + watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size; + watcher.IncludeSubdirectories = true; + watcher.EnableRaisingEvents = true; + watcher.Changed += FileSystemChanged; + await Utilities.CopyDirectory(_steamProcess.Downloader.ContentAppDepotDir, SelectedVersionInstallDir); + } // Create Junction Links for custom levels if (customLevelsLinkCheckbox.IsChecked.GetValueOrDefault()) diff --git a/LegacyInstaller/Utilities.cs b/LegacyInstaller/Utilities.cs index d2a7b7c..737ed82 100644 --- a/LegacyInstaller/Utilities.cs +++ b/LegacyInstaller/Utilities.cs @@ -30,6 +30,11 @@ public static async Task CopyDirectory(string sourceDir, string targetDir) catch { } } + public static void MoveDirectory(string sourceDir, string targetDir) + { + Directory.Move(sourceDir, targetDir); + } + public static int Search(byte[] src, byte[] pattern) { int maxFirstCharSlot = src.Length - pattern.Length + 1;