Soenneker.Utils.Directory
4.0.916
Prefix Reserved
dotnet add package Soenneker.Utils.Directory --version 4.0.916
NuGet\Install-Package Soenneker.Utils.Directory -Version 4.0.916
<PackageReference Include="Soenneker.Utils.Directory" Version="4.0.916" />
<PackageVersion Include="Soenneker.Utils.Directory" Version="4.0.916" />
<PackageReference Include="Soenneker.Utils.Directory" />
paket add Soenneker.Utils.Directory --version 4.0.916
#r "nuget: Soenneker.Utils.Directory, 4.0.916"
#:package Soenneker.Utils.Directory@4.0.916
#addin nuget:?package=Soenneker.Utils.Directory&version=4.0.916
#tool nuget:?package=Soenneker.Utils.Directory&version=4.0.916
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 | 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
- Soenneker.Extensions.Task (>= 4.0.128)
- Soenneker.Utils.Path (>= 4.0.1209)
NuGet packages (22)
Showing the top 5 NuGet packages that depend on Soenneker.Utils.Directory:
| Package | Downloads |
|---|---|
|
Soenneker.Git.Util
Asynchronous Git operations, repository discovery, and bounded batch processing using bundled Git distributions. |
|
|
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). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.916 | 3,660 | 8/31/2026 |
| 4.0.915 | 283 | 8/31/2026 |
| 4.0.914 | 3,319 | 8/31/2026 |
| 4.0.913 | 2,947 | 8/31/2026 |
| 4.0.912 | 1,609 | 8/31/2026 |
| 4.0.911 | 410 | 8/30/2026 |
| 4.0.910 | 1,164 | 8/30/2026 |
| 4.0.909 | 2,718 | 8/30/2026 |
| 4.0.908 | 1,888 | 8/30/2026 |
| 4.0.907 | 1,823 | 8/30/2026 |
| 4.0.906 | 5,943 | 8/29/2026 |
| 4.0.905 | 1,348 | 8/29/2026 |
| 4.0.904 | 298 | 8/29/2026 |
| 4.0.903 | 3,755 | 8/29/2026 |
| 4.0.902 | 21,084 | 8/26/2026 |
| 4.0.901 | 1,059 | 8/25/2026 |
| 4.0.900 | 5,313 | 8/22/2026 |
| 4.0.899 | 1,530 | 8/22/2026 |
| 4.0.898 | 2,173 | 8/21/2026 |
| 4.0.897 | 9,379 | 8/18/2026 |
Update dependency Soenneker.Utils.Path to 4.0.1209 (#1508)