Soenneker.Utils.Directory
4.0.924
Prefix Reserved
dotnet add package Soenneker.Utils.Directory --version 4.0.924
NuGet\Install-Package Soenneker.Utils.Directory -Version 4.0.924
<PackageReference Include="Soenneker.Utils.Directory" Version="4.0.924" />
<PackageVersion Include="Soenneker.Utils.Directory" Version="4.0.924" />
<PackageReference Include="Soenneker.Utils.Directory" />
paket add Soenneker.Utils.Directory --version 4.0.924
#r "nuget: Soenneker.Utils.Directory, 4.0.924"
#:package Soenneker.Utils.Directory@4.0.924
#addin nuget:?package=Soenneker.Utils.Directory&version=4.0.924
#tool nuget:?package=Soenneker.Utils.Directory&version=4.0.924
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)
- Soenneker.Extensions.Task (>= 4.0.128)
- Soenneker.Utils.Path (>= 4.0.1216)
NuGet packages (18)
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 |
|---|---|---|
| 4.0.924 | 0 | 9/7/2026 |
| 4.0.923 | 7,344 | 9/5/2026 |
| 4.0.922 | 6,457 | 9/4/2026 |
| 4.0.921 | 5,905 | 9/4/2026 |
| 4.0.920 | 50 | 9/4/2026 |
| 4.0.919 | 6,616 | 9/4/2026 |
| 4.0.918 | 8,796 | 9/4/2026 |
| 4.0.917 | 1,888 | 9/4/2026 |
| 4.0.916 | 10,686 | 8/31/2026 |
| 4.0.915 | 318 | 8/31/2026 |
| 4.0.914 | 3,622 | 8/31/2026 |
| 4.0.913 | 3,227 | 8/31/2026 |
| 4.0.912 | 1,713 | 8/31/2026 |
| 4.0.911 | 464 | 8/30/2026 |
| 4.0.910 | 1,210 | 8/30/2026 |
| 4.0.909 | 2,885 | 8/30/2026 |
| 4.0.908 | 1,979 | 8/30/2026 |
| 4.0.907 | 1,910 | 8/30/2026 |
| 4.0.906 | 6,002 | 8/29/2026 |
| 4.0.905 | 1,496 | 8/29/2026 |
Updated Soenneker.Utils.Path to 4.0.1216