FolderScanToTxt 1.0.0

dotnet add package FolderScanToTxt --version 1.0.0
                    
NuGet\Install-Package FolderScanToTxt -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FolderScanToTxt" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FolderScanToTxt" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="FolderScanToTxt" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FolderScanToTxt --version 1.0.0
                    
#r "nuget: FolderScanToTxt, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FolderScanToTxt@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FolderScanToTxt&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=FolderScanToTxt&version=1.0.0
                    
Install as a Cake Tool

FolderScanToTxt

FolderScanToTxt is a lightweight .NET library for scanning directories, filtering files/folders, and exporting the structure to a text file. It is designed to be UI-agnostic, so you can use it in console apps, desktop apps, or web applications.

Quick Start

using FolderScanToTxt;

class Program
{
    static void Main()
    {
        var options = new FolderScanOptions
        {
            IncludeHidden = false,
            FileTypeFilter = ".txt",
            ExcludeFileName1 = "app.exe",
            ExcludeFileName2 = "folder-contents.txt"
        };

        var result = FolderScannerService.ScanAndSave(
            baseDirectory: @"C:\MyFolder",
            outputFileName: "folder-contents.txt",
            options: options
        );

        Console.WriteLine($"Done! Files: {result.FileCount}, Folders: {result.FolderCount}");
    }
}

Features

  • Scan directories and list all files/folders.
  • Optionally include or exclude hidden files/folders.
  • Filter by specific file type (e.g., .txt, .mp3).
  • Exclude specific files (e.g., the scanner’s own executable).
  • Save results to a .txt file.
  • Optional console helpers for interactive prompts.

Installation

From NuGet.org

dotnet add package FolderScanToTxt

Then install:

dotnet add package FolderScanToTxt

Usage

Using Console Helpers (Optional)

bool includeHidden = ConsoleHelpers.PromptHiddenFiles();
string? filter = ConsoleHelpers.PromptFileType();

var options = new FolderScanOptions
{
    IncludeHidden = includeHidden,
    FileTypeFilter = filter,
    ExcludeFileName1 = "app.exe",
    ExcludeFileName2 = "folder-contents.txt"
};

FolderScannerService.ScanAndSave(@"C:\MyFolder", "folder-contents.txt", options);

You can also check a console project that uses this library at: FolderToTxt

Output Example

MyFolder/
 ├── doc.txt
 ├── image.png
 └── SubFolder/
     ├── notes.txt
     └── song.mp3

The exported folder-contents.txt might look like:

SubFolder/
../notes.txt
../song.mp3
doc.txt
image.png

API Overview

  • FolderScanToTxt

    • ScanAndSave(string baseDirectory, string outputFileName, FolderScanOptions options)
  • FolderScanOptions

    • bool IncludeHidden → include hidden files/folders.
    • string? FileTypeFilter → e.g. .txt or .mp3.
    • string? ExcludeFileName1, ExcludeFileName2 → filenames to skip.
  • FolderScanResult

    • int FileCount
    • int FolderCount
    • string OutputPath
  • ConsoleHelpers (Optional)

    • PromptHiddenFiles(string message = "...")
    • PromptFileType(string message = "...")

License

MIT License. See LICENSE

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 192 9/2/2025