Soenneker.Utils.FileSync
4.0.2010
Prefix Reserved
dotnet add package Soenneker.Utils.FileSync --version 4.0.2010
NuGet\Install-Package Soenneker.Utils.FileSync -Version 4.0.2010
<PackageReference Include="Soenneker.Utils.FileSync" Version="4.0.2010" />
<PackageVersion Include="Soenneker.Utils.FileSync" Version="4.0.2010" />
<PackageReference Include="Soenneker.Utils.FileSync" />
paket add Soenneker.Utils.FileSync --version 4.0.2010
#r "nuget: Soenneker.Utils.FileSync, 4.0.2010"
#:package Soenneker.Utils.FileSync@4.0.2010
#addin nuget:?package=Soenneker.Utils.FileSync&version=4.0.2010
#tool nuget:?package=Soenneker.Utils.FileSync&version=4.0.2010
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 | 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
- Soenneker.Extensions.FileInfo (>= 4.0.612)
- Soenneker.Extensions.Stream (>= 4.0.146)
- Soenneker.Utils.Directory (>= 4.0.916)
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 | 0 | 9/1/2026 |
| 4.0.2009 | 0 | 8/31/2026 |
| 4.0.2008 | 25 | 8/31/2026 |
| 4.0.2007 | 42 | 8/31/2026 |
| 4.0.2006 | 31 | 8/31/2026 |
| 4.0.2005 | 37 | 8/30/2026 |
| 4.0.2004 | 33 | 8/30/2026 |
| 4.0.2003 | 104 | 8/30/2026 |
| 4.0.2002 | 40 | 8/30/2026 |
| 4.0.2001 | 39 | 8/30/2026 |
| 4.0.2000 | 38 | 8/30/2026 |
| 4.0.1998 | 37 | 8/30/2026 |
| 4.0.1997 | 37 | 8/30/2026 |
| 4.0.1996 | 42 | 8/29/2026 |
| 4.0.1995 | 37 | 8/29/2026 |
| 4.0.1993 | 36 | 8/29/2026 |
| 4.0.1992 | 70 | 8/26/2026 |
| 4.0.1991 | 70 | 8/26/2026 |
| 4.0.1990 | 71 | 8/26/2026 |
| 4.0.1989 | 79 | 8/25/2026 |
Updated NuGet packages