public static void ExtractAllFiles(string ParentPath, TreeNodeCollection Nodes)
        {
            FolderSelectDialog folderDialog = new FolderSelectDialog();

            if (folderDialog.ShowDialog() == DialogResult.OK)
            {
                STProgressBar progressBar = new STProgressBar();
                progressBar.Task = "Extracing Files...";
                progressBar.Refresh();
                progressBar.Value         = 0;
                progressBar.StartPosition = FormStartPosition.CenterScreen;
                progressBar.Show();

                var Collection = TreeViewExtensions.Collect(Nodes);

                int Curfile = 0;
                foreach (TreeNode file in Collection)
                {
                    if (file is ArchiveFileWrapper)
                    {
                        string FilePath      = ((ArchiveFileWrapper)file).ArchiveFileInfo.FileName;
                        string FolderPath    = Path.GetDirectoryName(FilePath.RemoveIllegaleFolderNameCharacters());
                        string FolderPathDir = Path.Combine(folderDialog.SelectedPath, FolderPath);

                        if (!Directory.Exists(FolderPathDir))
                        {
                            Directory.CreateDirectory(FolderPathDir);
                        }

                        string FileName = file.Text.RemoveIllegaleFileNameCharacters();

                        FilePath = Path.Combine(FolderPath, FileName);

                        if (ParentPath != string.Empty)
                        {
                            FilePath = FilePath.Replace(ParentPath, string.Empty);
                        }

                        var path = Path.Combine(folderDialog.SelectedPath, FilePath);

                        progressBar.Task  = $"Extracting File {file}";
                        progressBar.Value = (Curfile++ *100) / Collection.Count();
                        progressBar.Refresh();
                        CreateDirectoryIfExists($"{path}");

                        if (file is ArchiveFileWrapper)
                        {
                            File.WriteAllBytes($"{path}",
                                               ((ArchiveFileWrapper)file).ArchiveFileInfo.FileData);
                        }
                    }
                }

                progressBar.Value = 100;
                progressBar.Refresh();
                progressBar.Close();
            }
        }
Beispiel #2
0
        private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            e.DrawDefault = true;

            if (e.Node is STGenericObject || e.Node is STGenericModel)
            {
            }
            else
            {
                TreeViewExtensions.HideCheckBox(e.Node);
            }
        }
        public static void RemoveFolder(TreeNode folderNode, IArchiveFile archiveFile)
        {
            if (!archiveFile.CanDeleteFiles)
            {
                return;
            }

            foreach (var node in TreeViewExtensions.Collect(folderNode.Nodes))
            {
                var parentNode = node.Parent;
                parentNode.Nodes.Remove(node);

                if (node is ArchiveFileWrapper)
                {
                    archiveFile.DeleteFile(((ArchiveFileWrapper)node).ArchiveFileInfo);
                }
            }
        }