private void ReplaceAction(object sender, EventArgs args) { //Add folders and files from selected path FolderSelectDialog ofd = new FolderSelectDialog(); if (ofd.ShowDialog() == DialogResult.OK) { //Clear all nodes foreach (var node in TreeViewExtensions.Collect(Nodes)) { if (node is ArchiveFileWrapper) { ArchiveFile.DeleteFile(((ArchiveFileWrapper)node).ArchiveFileInfo); } } Nodes.Clear(); var proccessedFiles = TreeHelper.ReadFiles(ofd.SelectedPath); string folderPath = TreeHelper.GetFolderAbsoultePath(this, RootNode); for (int i = 0; i < proccessedFiles.Count; i++) { ArchiveFile.AddFile(new ArchiveFileInfo() { FileName = $"{folderPath}/{proccessedFiles[i].Item1}", FileData = File.ReadAllBytes(proccessedFiles[i].Item2), }); } RootNode.FillTreeNodes(); } }
private void RepackAction(object sender, EventArgs args) { FolderSelectDialog dlg = new FolderSelectDialog(); if (dlg.ShowDialog() == DialogResult.OK) { string FolderPath = dlg.SelectedPath; STProgressBar progressBar = new STProgressBar(); progressBar.Task = "Reading Directory..."; progressBar.Value = 0; progressBar.StartPosition = FormStartPosition.CenterScreen; progressBar.Show(); progressBar.Refresh(); var ProccessedFiles = TreeHelper.ReadFiles(FolderPath); progressBar.Task = "Repacking Files..."; progressBar.Refresh(); ArchiveFile.ClearFiles(); for (int i = 0; i < ProccessedFiles.Count; i++) { progressBar.Value = (i * 100) / ProccessedFiles.Count; progressBar.Task = $"Packing {ProccessedFiles[i].Item1}"; progressBar.Refresh(); ArchiveFile.AddFile(new ArchiveFileInfo() { FileName = ProccessedFiles[i].Item1, FileData = File.ReadAllBytes(ProccessedFiles[i].Item2), }); } progressBar.Close(); progressBar.Dispose(); ProccessedFiles.Clear(); GC.Collect(); FillTreeNodes(); } }