Soenneker.Utils.FileSync 4.0.2005

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 4.0.2005
                    
NuGet\Install-Package Soenneker.Utils.FileSync -Version 4.0.2005
                    
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.2005" />
                    
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.2005" />
                    
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.2005
                    
#r "nuget: Soenneker.Utils.FileSync, 4.0.2005"
                    
#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.2005
                    
#: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.2005
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.FileSync&version=4.0.2005
                    
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.2010 53 9/1/2026
4.0.2009 52 8/31/2026
4.0.2008 51 8/31/2026
4.0.2007 63 8/31/2026
4.0.2006 51 8/31/2026
4.0.2005 57 8/30/2026
4.0.2004 54 8/30/2026
4.0.2003 124 8/30/2026
4.0.2002 61 8/30/2026
4.0.2001 59 8/30/2026
4.0.2000 58 8/30/2026
4.0.1998 59 8/30/2026
4.0.1997 59 8/30/2026
4.0.1996 61 8/29/2026
4.0.1995 57 8/29/2026
4.0.1993 55 8/29/2026
4.0.1992 81 8/26/2026
4.0.1991 84 8/26/2026
4.0.1990 87 8/26/2026
4.0.1989 93 8/25/2026
Loading failed

Update dependency Soenneker.Extensions.Stream to 4.0.145 (#2683)