Soenneker.Utils.Path 11.0.1275

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

alternate text is missing from this package README image Soenneker.Utils.Path

Reserves collision-free file names, creates unique temporary directories, and generates GUID-based path candidates.

Installation

dotnet add package Soenneker.Utils.Path

Quick start

using Soenneker.Utils.Path.Registrars;

services.AddPathUtilAsSingleton();

Then inject IPathUtil wherever you need it.

GetTempDirectory and GetLastPathSegment are static helpers on PathUtil. The unique-path and temp-directory operations are exposed through IPathUtil.

Reserve a file name from a URI

string path = await pathUtil.GetUniqueFilePathFromUri(
    downloadDirectory,
    "https://example.com/files/report.pdf",
    cancellationToken);

This method extracts the URI path's file name and atomically creates an empty file to reserve it. If report.pdf already exists, it tries report(1).pdf, report(2).pdf, and so on. The directory must already exist. The caller owns the reserved file and should overwrite it or delete it when no longer needed. Non-collision filesystem failures propagate rather than being retried forever.

Generate random candidate paths

string candidate = await pathUtil.GetRandomUniqueFilePath(outputDirectory, ".json", cancellationToken);
string tempCandidate = await pathUtil.GetRandomTempFilePath("tmp", cancellationToken);

These methods return GUID-based paths that did not exist when checked; they do not create or reserve files. Another process can claim a result before it is opened. Use FileMode.CreateNew when the caller needs atomic ownership and retry on a collision. Extensions with or without a leading dot are accepted; path components are discarded.

Create a temporary directory

string workspace = await pathUtil.GetUniqueTempDirectory("import", create: true, cancellationToken);

try
{
    // Use workspace.
}
finally
{
    Directory.Delete(workspace, recursive: true);
}

The default create: true atomically creates a GUID-suffixed directory below the process temp directory. With create: false, the method only returns a currently unused candidate and has the same check-then-use race as random file paths. Prefix path components are removed. Cleanup remains the caller's responsibility.

PathUtil.GetTempDirectory() returns the process-cached value of Path.GetTempPath(). PathUtil.GetLastPathSegment(path) ignores trailing platform directory separators and returns null for empty or separator-only input; it does not access the filesystem.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Soenneker.Utils.Path:

Package Downloads
Soenneker.Utils.Directory

A utility library encapsulating various directory methods

Soenneker.Blob.Download

A utility library for Azure Blob download operations

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.Pdfs.Processor

A PDF-library-free .NET utility for replacing text, merging, cleaning, and optimizing PDF documents.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1275 4,539 11/11/2026
11.0.1274 2,915 11/11/2026
11.0.1273 1,663 11/11/2026
11.0.1272 1,691 11/11/2026
11.0.1271 381 11/11/2026
11.0.1270 2,419 11/11/2026
11.0.1269 16,379 11/3/2026
11.0.1268 2,268 11/3/2026
11.0.1267 3,733 11/2/2026
11.0.1266 20,913 10/26/2026
11.0.1265 168 10/26/2026
4.0.1264 22,926 10/15/2026
4.0.1263 98 10/15/2026
4.0.1262 132 10/14/2026
4.0.1261 1,023 10/14/2026
4.0.1259 2,938 10/14/2026
4.0.1258 3,368 10/14/2026
4.0.1251 2,291 10/13/2026
4.0.1250 1,211 10/13/2026
4.0.1247 7,409 10/12/2026
Loading failed

Updated Soenneker.Extensions.String to 11.0.820