Soenneker.Utils.FileSync 11.0.2098

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

Soenneker.Utils.FileSync

DI-friendly synchronous file reading, writing, copying, moving, enumeration, attribute cleanup, and deletion.

Installation

dotnet add package Soenneker.Utils.FileSync

Registration

builder.Services.AddFileUtilSyncAsSingleton();

Scoped registration is also available with AddFileUtilSyncAsScoped().

All operations block the calling thread. Use this package for genuinely synchronous workflows; use Soenneker.Utils.File on request, UI, or other threads where blocking I/O harms responsiveness.

Read and write

string text = files.Read(path);
byte[] bytes = files.ReadToBytes(path);
List<string> lines = files.ReadAsLines(path);

files.Write(path, text);
files.WriteAllLines(path, lines);

Whole-file operations materialize the complete contents. The stream overload rewinds the supplied stream to position zero, copies it, and leaves the source open; it therefore requires a seekable source.

FileUtilSync.GetTempFileName() returns a unique candidate path under the system temporary directory. It does not create or reserve the file, so another actor can claim the path before it is used.

Copy and move

files.Copy(sourceFile, destinationFile);
files.Move(sourceFile, destinationFile);

files.CopyDirectory(sourceDirectory, destinationDirectory, overwrite: true);
files.CopyRecursively(sourceDirectory, destinationDirectory, overwrite: true);

Single-file Copy() and Move() do not overwrite an existing destination or create its parent directory. CopyDirectory() creates the destination but copies only top-level files. CopyRecursively() creates the directory tree and copies descendants while skipping symbolic links, junctions, and other reparse points.

Copy operations are incremental rather than transactional. If a later file fails, earlier destination files remain copied.

Deletion and bulk changes

bool deleted = files.DeleteIfExists(path);
bool attempted = files.TryDelete(path);

files.DeleteAll(rootDirectory);
files.TryRemoveReadonlyAndArchiveAttributesFromAll(rootDirectory);

DeleteAll() recursively deletes discovered files but leaves directories in place. Its Try* counterpart processes files best-effort and logs failures. Recursive safe enumeration skips inaccessible paths and reparse points.

RenameAllInDirectoryRecursively() performs a literal, case-sensitive replacement over each full file path and moves files one at a time. It does not rename empty directories, create missing destination parents, detect all conflicts in advance, or roll back earlier moves. Use it only with a validated root and review broad renames in version control.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.2099 110 11/19/2026
11.0.2098 97 11/18/2026
11.0.2097 92 11/18/2026
11.0.2096 90 11/18/2026
11.0.2095 138 11/15/2026
11.0.2094 186 11/11/2026
11.0.2093 101 11/11/2026
11.0.2092 112 11/11/2026
11.0.2091 108 11/11/2026
11.0.2089 102 11/11/2026
11.0.2088 104 11/11/2026
11.0.2086 100 11/11/2026
11.0.2085 90 11/11/2026
11.0.2084 573 11/3/2026
11.0.2083 110 11/3/2026
11.0.2082 115 11/3/2026
11.0.2081 269 10/27/2026
11.0.2080 106 10/27/2026
11.0.2079 109 10/26/2026
11.0.2078 109 10/26/2026
Loading failed

Updated Multiple NuGet packages