← Back to Home • Next: MultiFile — Methods →
A lazy-loaded file-system tree where the user checks several files and/or folders and confirms with Enter.
MultiFile is the multiple-selection sibling of File. It renders the file
system as an expandable/collapsible tree rooted at a folder you choose, loading each directory’s
contents only when it is expanded. Checked entries are tracked by their full path, so a selection
survives collapsing and re-expanding the branch that contains it. Beyond the shared browsing
options, it adds cascade checking, recursive folder marking, a min/max count range, and a check
predicate.
🔘 Only need one file or folder? Use the File control — same tree browser, single selection.
| Sub-page | What you will find |
|---|---|
| Index (this page) | What it is, when to use it, first examples, the method map |
| Methods | Every fluent method — signature, parameters, defaults, and a snippet |
| Operations | Keyboard, checking, cascade/recursive marking, range, history |
| Styles | The MultiFileStyles regions and how to recolor them |
Use MultiFile when… |
Consider instead… |
|---|---|
| The user checks several files/folders from disk | — |
| The user picks exactly one file/folder | File |
| The data is an arbitrary hierarchy (not the file system) | TreeSelect |
| The choices are an in-memory list | MultiSelect |
using PromptPlusLibrary;
var result = PromptPlus.Controls
.MultiFile("Check files or folders")
.Root(@"C:\Projects")
.Run();
if (!result.IsAborted)
{
foreach (var f in result.Content)
PromptPlus.Console.WriteLine(f.FullPath);
}
MultiFile("Check files or folders") creates the browser; the argument is the prompt text..Root(...) sets the folder the tree starts at. Without it, the current directory is used..Run() renders the tree and blocks until Enter (confirm) or Esc (abort), returning a
ResultPrompt<FileItem[]>.Run() returns ResultPrompt<FileItem[]> — an array of the checked entries. FileItem is a small
sealed class (not System.IO.FileInfo):
var result = PromptPlus.Controls.MultiFile("Check files").Root(root).Run();
if (!result.IsAborted)
{
PromptPlus.Console.WriteLine($"Checked {result.Content.Length} item(s):");
foreach (var f in result.Content)
PromptPlus.Console.WriteLine($" {f.FullPath} (dir: {f.IsDirectory}, size: {f.Length})");
}
When aborted, .Content is an empty array. FileItem.ToString() returns FullPath.
using PromptPlusLibrary;
var result = PromptPlus.Controls
.MultiFile("Check C# files", "Space to check, Enter to confirm")
.Root(@"C:\Projects")
.SearchPattern("*.cs") // only *.cs files are listed (folders always show)
.SelectFilesOnly() // folders can be expanded but not checked
.Range(2, 4) // require between 2 and 4 checked items
.Run();
This combines a file filter, a check rule, and a count range — see Operations for how they behave together.
Grouped by purpose. Full signatures and examples are on the Methods page.
| Purpose | Methods |
|---|---|
| Choose the root | Root |
| Filter what is listed | SearchPattern, OnlyFolders, ShowHidden, ShowSystem |
| Check rules | SelectFilesOnly, CascadeCheck, RecursiveMarkWithCtrlSpace, Range |
| Validate a check | PredicateChecked, PredicateCheckedAsync |
| Layout & display | HideSize, ShowFullPath, PageSize |
| Initial values | Default |
| History | EnableHistory |
| Appearance & behavior | Styles, Options |
| Run | Run |
MultiFile returns ResultPrompt<FileItem[]> — the checked entries.
| Member | Meaning |
|---|---|
.Content |
The checked FileItem array (empty if aborted) |
.IsAborted |
true when the user pressed Esc |
var (items, aborted) = PromptPlus.Controls.MultiFile("Check").Root(root).Run();
if (!aborted)
foreach (var f in items) PromptPlus.Console.WriteLine(f.FullPath);