Soenneker.Utils.Directory 11.0.971

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.Directory --version 11.0.971
                    
NuGet\Install-Package Soenneker.Utils.Directory -Version 11.0.971
                    
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="Soenneker.Utils.Directory" Version="11.0.971" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Directory" Version="11.0.971" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.Directory" />
                    
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 Soenneker.Utils.Directory --version 11.0.971
                    
#r "nuget: Soenneker.Utils.Directory, 11.0.971"
                    
#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 Soenneker.Utils.Directory@11.0.971
                    
#: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=Soenneker.Utils.Directory&version=11.0.971
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Directory&version=11.0.971
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Utils.Directory

DI-friendly directory creation, enumeration, copying, moving, deletion, size calculation, and temporary-directory helpers.

Installation

dotnet add package Soenneker.Utils.Directory

Registration

builder.Services.AddDirectoryUtilAsSingleton();

AddDirectoryUtilAsScoped() is also available. Both registrations include the matching IPathUtil lifetime.

Common operations

bool created = await directories.Create(outputPath, cancellationToken: cancellationToken);
bool exists = await directories.Exists(outputPath, cancellationToken);

List<string> children = await directories.GetAllDirectories(outputPath, cancellationToken);
List<string> descendants = await directories.GetAllDirectoriesRecursively(outputPath, cancellationToken);

await directories.CopyDirectory(sourcePath, destinationPath, overwrite: false, cancellationToken);
await directories.Move(sourcePath, archivePath, cancellationToken: cancellationToken);

Create() and TryCreate() return false when the path already exists. CreateStrict() throws in that case. CopyDirectory(..., overwrite: false) keeps existing destination files and continues copying other entries; it is not an all-or-nothing operation.

Copy and recursive size/empty-directory scans do not follow symbolic links, junctions, or other reparse points. This keeps traversal inside the requested directory tree. Reparse-point entries themselves are skipped by copy and size scans and prevent a directory from being considered empty.

Destructive operations

await directories.DeleteIfExists(path, cancellationToken);
await directories.DeleteEmptyDirectories(root, cancellationToken);

Delete() recursively removes the supplied directory and throws when it does not exist. DeleteIfExists() is idempotent. Resolve and validate paths at the application boundary before passing user-controlled values to either method.

Cancellation is cooperative and does not roll back filesystem changes that already completed. MoveContentsUpOneLevelStrict() can likewise leave earlier entries moved if a later conflict, I/O error, or cancellation occurs.

Temporary directories and size

string tempDirectory = await directories.CreateTempDirectory(cancellationToken);

long bytes = await directories.GetSizeInBytes(
    path,
    new GetSizeOptions
    {
        Recursive = true,
        ContinueOnError = false,
        Progress = progress
    },
    cancellationToken);

CreateTempDirectory() returns a unique path and creates it. The static DirectoryUtil.GetNewTempDirectoryPath() only generates a candidate path; it does not create anything.

Size calculation returns 0 for a missing directory. With ContinueOnError = true, inaccessible or failed subtrees are logged and omitted from the result; set it to false when a partial total is unacceptable.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (21)

Showing the top 5 NuGet packages that depend on Soenneker.Utils.Directory:

Package Downloads
Soenneker.Utils.FileSync

A utility library encapsulating synchronous file IO operations

Soenneker.Utils.Dotnet

A utility library for the dotnet executable

Soenneker.Utils.SHA3

A utility library for SHA-3 hashing

Soenneker.Hashing.Blake3

A high-performance .NET library for BLAKE3 hashing and constant-time verification. Pure C# with optional SIMD acceleration (AVX2 on x64, NEON on ARM).

Soenneker.OpenApi.Fixer

Normalizes OpenAPI documents for generated-client compatibility

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1002 1,745 12/3/2026
11.0.1001 1,788 12/3/2026
11.0.1000 1,470 12/2/2026
11.0.999 1,087 12/2/2026
11.0.998 630 12/2/2026
11.0.997 819 12/2/2026
11.0.996 1,201 12/2/2026
11.0.995 2,715 12/2/2026
11.0.994 3,469 12/2/2026
11.0.993 2,636 12/1/2026
11.0.992 2,792 12/1/2026
11.0.991 82 12/1/2026
11.0.990 4,107 12/1/2026
11.0.989 2,080 11/30/2026
11.0.988 92 11/30/2026
11.0.987 4,942 11/30/2026
11.0.986 15,757 11/18/2026
11.0.985 1,264 11/18/2026
11.0.982 4,810 11/18/2026
11.0.971 3,739 11/3/2026
Loading failed

Updated Multiple NuGet packages