Soenneker.Utils.Directory 4.0.910

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 4.0.910
                    
NuGet\Install-Package Soenneker.Utils.Directory -Version 4.0.910
                    
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="4.0.910" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Directory" Version="4.0.910" />
                    
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 4.0.910
                    
#r "nuget: Soenneker.Utils.Directory, 4.0.910"
                    
#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@4.0.910
                    
#: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=4.0.910
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Directory&version=4.0.910
                    
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 net10.0 is compatible.  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.

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.Git.Util

Asynchronous Git operations, repository discovery, and bounded batch processing using bundled Git distributions.

Soenneker.Utils.Dotnet

A utility library for the dotnet executable

Soenneker.Utils.File.Download

Provides a flexible utility for downloading files from specified URIs, with thread-safe concurrency and automatic file name conflict handling

Soenneker.Utils.SHA3

A utility library for SHA-3 hashing

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.912 0 8/31/2026
4.0.911 0 8/30/2026
4.0.910 0 8/30/2026
4.0.909 286 8/30/2026
4.0.908 584 8/30/2026
4.0.907 1,081 8/30/2026
4.0.906 2,899 8/29/2026
4.0.905 808 8/29/2026
4.0.904 252 8/29/2026
4.0.903 2,543 8/29/2026
4.0.902 13,186 8/26/2026
4.0.901 997 8/25/2026
4.0.900 5,275 8/22/2026
4.0.899 1,529 8/22/2026
4.0.898 2,169 8/21/2026
4.0.897 9,369 8/18/2026
4.0.896 2,227 8/18/2026
4.0.895 10,301 8/12/2026
4.0.894 4,181 8/12/2026
4.0.893 208 8/11/2026
Loading failed

Keep directory traversal inside requested trees