Soenneker.Utils.Directory
11.0.980
Prefix Reserved
dotnet add package Soenneker.Utils.Directory --version 11.0.980
NuGet\Install-Package Soenneker.Utils.Directory -Version 11.0.980
<PackageReference Include="Soenneker.Utils.Directory" Version="11.0.980" />
<PackageVersion Include="Soenneker.Utils.Directory" Version="11.0.980" />
<PackageReference Include="Soenneker.Utils.Directory" />
paket add Soenneker.Utils.Directory --version 11.0.980
#r "nuget: Soenneker.Utils.Directory, 11.0.980"
#:package Soenneker.Utils.Directory@11.0.980
#addin nuget:?package=Soenneker.Utils.Directory&version=11.0.980
#tool nuget:?package=Soenneker.Utils.Directory&version=11.0.980
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.Task (>= 11.0.143)
- Soenneker.Utils.Path (>= 11.0.1275)
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.980 | 2,183 | 11/11/2026 |
| 11.0.979 | 210 | 11/11/2026 |
| 11.0.978 | 1,920 | 11/11/2026 |
| 11.0.977 | 2,158 | 11/11/2026 |
| 11.0.976 | 1,868 | 11/11/2026 |
| 11.0.975 | 1,267 | 11/11/2026 |
| 11.0.973 | 16,707 | 11/3/2026 |
| 11.0.972 | 2,244 | 11/3/2026 |
| 11.0.971 | 3,726 | 11/3/2026 |
| 11.0.970 | 21,656 | 10/26/2026 |
| 11.0.969 | 1,401 | 10/26/2026 |
| 11.0.968 | 456 | 10/26/2026 |
| 4.0.967 | 21,544 | 10/15/2026 |
| 4.0.966 | 133 | 10/15/2026 |
| 4.0.965 | 2,663 | 10/14/2026 |
| 4.0.963 | 3,168 | 10/14/2026 |
| 4.0.962 | 4,071 | 10/14/2026 |
| 4.0.954 | 5,659 | 10/13/2026 |
| 4.0.951 | 14,628 | 10/11/2026 |
| 4.0.950 | 1,069 | 10/11/2026 |
Updated Multiple NuGet packages