Soenneker.Utils.FileSync 4.0.2047

Prefix Reserved
dotnet add package Soenneker.Utils.FileSync --version 4.0.2047
                    
NuGet\Install-Package Soenneker.Utils.FileSync -Version 4.0.2047
                    
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="4.0.2047" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.FileSync" Version="4.0.2047" />
                    
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 4.0.2047
                    
#r "nuget: Soenneker.Utils.FileSync, 4.0.2047"
                    
#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@4.0.2047
                    
#: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=4.0.2047
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.FileSync&version=4.0.2047
                    
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 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. 
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
4.0.2047 53 9/25/2026
4.0.2046 68 9/25/2026
4.0.2045 75 9/25/2026
4.0.2044 33 9/24/2026
4.0.2043 34 9/24/2026
4.0.2042 70 9/24/2026
4.0.2041 125 9/16/2026
4.0.2040 92 9/16/2026
4.0.2039 89 9/16/2026
4.0.2038 88 9/16/2026
4.0.2037 83 9/15/2026
4.0.2035 91 9/13/2026
4.0.2034 92 9/13/2026
4.0.2033 83 9/13/2026
4.0.2032 87 9/12/2026
4.0.2031 85 9/12/2026
4.0.2030 91 9/12/2026
4.0.2025 111 9/9/2026
4.0.2024 96 9/9/2026
4.0.2023 102 9/8/2026
Loading failed

Updated NuGet packages