private void AddToModBulk(string[] files, Action <Progress> ProgressChanged = null) { if (editingBulk) { return; } int i = 0; string phaseStr = "Importing {0} of {1} files/folders - {2}"; foreach (string filePath in files) { Action <Progress> PhasedProgressChanged = Progress.BuildPhasedProgressChanged(ProgressChanged, phaseStr, i++, files.Length); string fileExtension = Path.GetExtension(filePath); string fileName = Path.GetFileName(filePath); string longFilePath = ModInstallations.EnsureLongPathSupport(filePath); if (Directory.Exists(longFilePath)) { ModInstallations.AddFolder(editedMod, filePath, true, PhasedProgressChanged); } else if ((new string[] { ".ba2", ".zip", ".rar", ".tar", ".7z" }).Contains(fileExtension.ToLower())) { ModInstallations.AddArchive(editedMod, filePath, PhasedProgressChanged); } else { PhasedProgressChanged.Invoke(Progress.Indetermined($"Copying '{fileName}'...")); File.Copy(longFilePath, Path.Combine(editedMod.ManagedFolderPath, fileName), true); } } ProgressChanged?.Invoke(Progress.Done("File(s)/folder(s) added.")); }
private void AddFolderToModThreaded(string folderPath) { RunThreaded(() => { DisableUI(); }, () => { try { ModInstallations.AddFolder(editedMod, folderPath, false, UpdateProgress); } catch (Exception exc) { MsgBox.Get("failed").FormatText(exc.Message).Show(MessageBoxIcon.Error); return(false); } return(true); }, (success) => { EnableUI(); UpdateSidePanel(); }); }