API Reference
Class
FileSystemHelpers
File system utilities shared across hosts (CLI/PowerShell) and engine readers. Provides safe path resolution, size-capped reads, and disposable temp files with cleanup.
Inheritance
- Object
- FileSystemHelpers
Methods
public static TempFile CreateTempFile() #Returns:
TempFileCreates a disposable temp file that is deleted on Dispose.
public static String ReadAllTextCapped(String path, Int64 maxBytes = 16777216, OversizePolicy policy = Throw) #Returns:
StringReads all text from a file enforcing a maximum size.
Parameters
- path System.String
- Path to the file (relative paths resolved to full paths).
- maxBytes System.Int64 = 16777216
- Maximum allowed size in bytes; default 16 MB.
- policy ADPlayground.IO.FileSystemHelpers.OversizePolicy = Throw
- Oversize handling policy (Throw or ReturnEmpty).
Returns
File contents, or empty string when policy is ReturnEmpty and the file is oversized.
Exceptions
ArgumentException– Thrown when the path is empty, file is missing, or exceeds the size and policy is Throw.
public static String RequireReadableFile(String path, Int64 maxBytes = 67108864, String[] allowedExtensions = null) #Returns:
StringValidates that path points to an existing readable file and enforces a maximum size. Returns the absolute normalized path when validation succeeds.
Parameters
- path System.String
- Input path; relative paths are resolved to full paths.
- maxBytes System.Int64 = 67108864
- Maximum allowed file size in bytes (defaults to 64 MB).
- allowedExtensions System.String[] = null
- Optional whitelist of extensions (include dot), case-insensitive. When null, any extension is allowed.
Exceptions
ArgumentException– Thrown when the path is empty, file does not exist, exceeds size, or has a disallowed extension.