StarThrower.FileUtilities 2.0.0

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

StarThrower.FileUtilities

File and directory I/O helper methods for common read, write, and comparison operations.

StarThrower.FileUtilities provides FileSystem, a small static class with helpers for byte-level file comparison, writing text files, and bulk-deleting files in a directory.


Installation

dotnet add package StarThrower.FileUtilities

FileSystem

Method Description
FileCompare(string? file1, string? file2) Returns true if the two files have identical content (same length and byte-for-byte equal), or if file1 and file2 refer to the same path. Returns false otherwise.
WriteTextFile(string fileName, string text) Writes text to fileName, deleting and recreating the file if it already exists. Encodes the text as ASCII — characters outside the ASCII range will be replaced with ?.
DeleteFiles(string directory) Deletes every file directly inside directory on a best-effort basis. Subdirectories and their contents are left untouched. If one or more files fail to delete, every other file is still attempted, and an AggregateException collecting all the per-file failures is thrown once all files have been attempted.
using StarThrower.FileUtilities;

if (FileSystem.FileCompare(@"C:\data\a.txt", @"C:\data\b.txt"))
{
    Console.WriteLine("Files are identical.");
}

FileSystem.WriteTextFile(@"C:\output\report.txt", "Hello, world!");

// Clear out a temp directory (subfolders are preserved)
FileSystem.DeleteFiles(@"C:\temp\working");

Usage Notes

  • WriteTextFile uses ASCIIEncoding, not UTF-8. If you need to write non-ASCII text (accented characters, non-Latin scripts, etc.), encode the file yourself with File.WriteAllText and an explicit Encoding.
  • DeleteFiles is non-recursive by design — it will not remove subdirectories.
  • DeleteFiles deletes on a best-effort basis: a file that fails to delete (e.g. locked, permission denied) does not stop the rest from being deleted. Any failures are reported together via a single AggregateException thrown after every file has been attempted, with one inner exception per failed file.

Dependencies

None.


License

Copyright © 2026 Stephen Elmer. Licensed under the MIT License.

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.
  • net10.0

    • No dependencies.

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
2.0.0 96 7/4/2026