Soenneker.Utils.Directory
4.0.930
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.Directory --version 4.0.930
NuGet\Install-Package Soenneker.Utils.Directory -Version 4.0.930
<PackageReference Include="Soenneker.Utils.Directory" Version="4.0.930" />
<PackageVersion Include="Soenneker.Utils.Directory" Version="4.0.930" />
<PackageReference Include="Soenneker.Utils.Directory" />
paket add Soenneker.Utils.Directory --version 4.0.930
#r "nuget: Soenneker.Utils.Directory, 4.0.930"
#:package Soenneker.Utils.Directory@4.0.930
#addin nuget:?package=Soenneker.Utils.Directory&version=4.0.930
#tool nuget:?package=Soenneker.Utils.Directory&version=4.0.930
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.12)
- Soenneker.Extensions.Task (>= 4.0.128)
- Soenneker.Utils.Path (>= 4.0.1222)
NuGet packages (19)
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.944 | 3,083 | 9/16/2026 |
| 4.0.943 | 136 | 9/16/2026 |
| 4.0.942 | 91 | 9/16/2026 |
| 4.0.941 | 129 | 9/15/2026 |
| 4.0.939 | 10,016 | 9/13/2026 |
| 4.0.938 | 718 | 9/13/2026 |
| 4.0.937 | 1,708 | 9/13/2026 |
| 4.0.936 | 3,660 | 9/12/2026 |
| 4.0.935 | 3,642 | 9/12/2026 |
| 4.0.934 | 1,632 | 9/12/2026 |
| 4.0.933 | 124 | 9/12/2026 |
| 4.0.930 | 10,812 | 9/9/2026 |
| 4.0.929 | 2,968 | 9/9/2026 |
| 4.0.928 | 3,655 | 9/8/2026 |
| 4.0.927 | 6,495 | 9/8/2026 |
| 4.0.926 | 4,257 | 9/7/2026 |
| 4.0.925 | 3,003 | 9/7/2026 |
| 4.0.924 | 3,322 | 9/7/2026 |
| 4.0.923 | 13,655 | 9/5/2026 |
| 4.0.922 | 6,933 | 9/4/2026 |
Update dependency Soenneker.Utils.Path to 4.0.1222 (#1540)