← Back to Home • Next: File — Styles →
How the File control behaves while it is running: keyboard, tree navigation, filtering, selection
rules, history, and the values it returns.
Select a file or folder: index.md 1.2 KB ← prompt + live answer (path + size, follows the cursor)
Press + to expand, - to collapse ← description (optional) — NOT ←/→, see Tree navigation
C:\Projects ← root folder
├─ ▶ src ← collapsed folder (expand symbol)
├─ ▼ docs ← expanded folder
│ › index.md 1.2 KB ← focused item + size column
│ styles.md 3.4 KB
└─ README.md 0.8 KB
Page 1/2 ← pagination
Enter: select Esc: cancel ← tooltip
The answer line shows the size next to the path for a focused file (omitted for folders, and
omitted entirely when HideSize is set) — the same information as the list
row, but reachable via Home/End/←/→ scrolling if the path is too long to fit.
Every region can be recolored — see Styles.
File is a lazy tree browser: a folder’s children are read only when you expand it, and released
when you collapse it. This keeps memory proportional to what is visible, so it is safe to point
Root at a large drive.
| Key | Action |
|---|---|
↑ / ↓ |
Move focus up / down |
+ |
Expand the focused folder (plain → does not expand) |
- |
Collapse the focused folder (plain ← does not collapse) |
Tab |
On a folder: expand it (if needed) and move to its first child. On a file: move to the next item |
Shift+Tab |
On a folder’s first child: collapse the parent and move to it. Otherwise: move to the previous item |
Page Up / Page Down |
Jump one page |
Ctrl+Home / Ctrl+End |
First / last visible item (plain Home/End instead scroll the long-path answer text — see the anatomy note above) |
| Any printable character | Jump to the next visible entry whose name starts with that character (wraps around) |
Enter |
Confirm the focused entry (subject to the selection rule) |
Esc |
Abort → IsAborted == true |
Shift+F3 |
Toggle the answer between full path and short name |
F1 |
Cycle tooltip content |
Ctrl+F1 |
Show / hide the tooltip |
SearchPattern filters files by wildcard (e.g. *.cs);
directories are always shown so you can navigate into them.OnlyFolders hides files entirely — a folder picker.ShowHidden and ShowSystem add entries that
carry the Hidden/System attribute; both are off by default. ShowSystem has no effect at all on
non-Windows platforms (the System attribute isn’t checked there); ShowHidden on Unix uses a
separate check based on a leading dot in the file name, since Unix has no Hidden file attribute.HideSize removes the size column shown next to files.Pressing Enter confirms the focused entry and closes the control — but what counts as a valid selection depends on the configuration:
SelectFilesOnly, folders can be expanded and browsed, but only
a file can be confirmed.OnlyFolders, files are not listed at all, so only folders are
available.The confirmed entry is returned as a FileItem.
The answer line (and, when enabled, the summary) shows either the entry’s short name or its full
path. ShowFullPath sets the initial choice; the user can flip it at any
time with Shift+F3. This affects only the display — .Content.FullPath always carries the
complete path.
Default(fullPath) pre-selects an entry and expands the tree down to it when
the path lies under the Root.EnableHistory, the confirmed path is stored on disk; on the
next run it becomes the default and the tree expands to it (unless overridden by an explicit
Default with useDefaultHistory: false).MinPrefixLength, MaxItems, ExpirationTime, FilterType, PageSize) match
the Input history options.FileItem resultRun() returns ResultPrompt<FileItem?>. FileItem is a sealed class (not System.IO.FileInfo —
there is no FullName):
| Member | Type | Meaning |
|---|---|---|
FullPath |
string |
Full path on disk (ToString() returns this) |
Name |
string |
Display name of the entry |
IsDirectory |
bool |
true for folders |
Length |
long |
Size in bytes; 0 for directories |
LastWriteTime |
DateTime |
Last write timestamp |
var result = PromptPlus.Controls.File("Pick").Root(root).Run();
if (!result.IsAborted && result.Content is not null)
{
var f = result.Content;
PromptPlus.Console.WriteLine($"{f.FullPath} (dir: {f.IsDirectory}, size: {f.Length})");
}
Set per instance via Options(...), or globally on
PromptPlus.Config:
| Option | Effect on File |
|---|---|
EnabledAbortKey(false) |
Removes Esc — the user must choose |
HideAfterFinish(true) |
Erases the tree after confirm — the whole control is erased, not just the interactive part |
ShowTooltip(false) |
Hides the keyboard hint line |
Prompt(...) / Description(...) |
Overrides the prompt / description text |
PageSize can be set per control (PageSize) or globally
(PromptPlus.Config.PageSize).
.Content == null. Always branch on IsAborted before dereferencing.FileItem is not FileInfo — use FullPath, not FullName.Length is 0 for directories — check IsDirectory before treating it as a file size.SearchPattern filters files only — folders always appear so the tree remains navigable.Options