PromptPlus

PromptPlus # PromptPlus ## **File — Operations** [![NuGet](https://img.shields.io/badge/NuGet-PromptPlus-blue)](https://www.nuget.org/packages/PromptPlus) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![.NET](https://img.shields.io/badge/.NET-8%20%7C%209%20%7C%2010-512BD4)](https://dotnet.microsoft.com/)

← Back to HomeNext: File — Styles →


How the File control behaves while it is running: keyboard, tree navigation, filtering, selection rules, history, and the values it returns.


Anatomy of the control

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.


Tree navigation

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

What is listed


Selection rules

Pressing Enter confirms the focused entry and closes the control — but what counts as a valid selection depends on the configuration:

The confirmed entry is returned as a FileItem.


Full-path display

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.


Initial selection & history


The FileItem result

Run() 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})");
}

Options that change behavior

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).


Edge cases & gotchas


See also