Oakrey.Files 5.0.0

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

Oakrey.Files

Utilities for file naming, gzip compression and INI file handling.

Installation

dotnet add package Oakrey.Files

Package Manager Console:

Install-Package Oakrey.Files

File Names

FileNameGenerator creates names using predefined policies such as date/time, compact date/time, ticks, hexadecimal ticks, GUID and incremental values.

string name = FileNameGenerator.GetFileName("report", "txt", FileNamingPolicy.Incremental, string.Empty, 1);
// report_1.txt

For untrusted input, prefer the safe APIs. They replace path separators and invalid filename characters, normalize extensions and avoid Windows reserved device names.

string safeName = FileNameGenerator.GetSafeFileName("..\\unsafe/name", ".txt", FileNamingPolicy.Incremental, string.Empty, 1);
string safePath = FileNameGenerator.GetSafePathPath(folder, "..\\unsafe/name", ".txt", FileNamingPolicy.Incremental, string.Empty, 1);

FileNameSource stores naming settings and advances the incremental counter in a thread-safe way.

FileNameSource source = new(folder, "report", "txt", FileNamingPolicy.Incremental, string.Empty, 0);
string firstPath = source.GetSafeFilePath();
string secondPath = source.GetSafeFilePath();

GZip Compression

ZipCompression supports byte arrays, streams and files.

byte[] compressed = ZipCompression.Zip(data);
byte[] restored = ZipCompression.Unzip(compressed);

ZipCompression.Zip("input.txt", "output.gz");
ZipCompression.Unzip("output.gz", "restored.txt");

When decompressing untrusted data, set maxDecompressedBytes to reduce zip-bomb risk.

byte[] restored = ZipCompression.Unzip(compressed, maxDecompressedBytes: 10 * 1024 * 1024);

File destinations create missing directories automatically.

Basic INI Files

Oakrey.Files.Ini provides a simple key/value INI model.

IniFile ini = await IniReader.LoadAsync(new FileInfo("settings.ini"), CancellationToken.None);
ini.SetValue("app", "theme", "dark");
ini.SaveAtomic(new FileInfo("settings.ini"));

SaveAtomic writes through a temporary file and replaces the destination after a successful write.

Extended INI Files

Oakrey.Files.Ini.Extended preserves comments, blank lines, section inline comments and entry inline comments.

IniExtendedFile ini = Oakrey.Files.Ini.Extended.IniReader.Read(new FileInfo("settings.ini"));
ini.Set("app", "theme", "dark", "; user preference");
ini.SaveAtomic(new FileInfo("settings.ini"));

Project Information

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 (4)

Showing the top 4 NuGet packages that depend on Oakrey.Files:

Package Downloads
Oakrey.Applications.CustomLogging

A flexible and extensible .NET library for custom logging, supporting multiple logging engines, log broadcasting, and contextual logging with file path customization.

Oakrey.Applications.Trace

A .NET library for tracing application activities to files. Provides ITracer with start/stop control, real-time status and elapsed-time observables (Rx), configurable file paths and naming policies, synchronized UTF-8 file writing, monotonic elapsed-time measurement, and integration with Oakrey.Telemetry and Oakrey.Log.Abstractions.

Oakrey.Applications.Reporting

A .NET 11 library for structured, lifecycle-driven reporting. Defines IReporter and IReportConsumer generics with a TStatus enum, supporting report/block/item lifecycle events, evidence attachment, key-value metadata, and file output via FileReporter. RunnableReporter fans out to multiple consumers simultaneously.

Oakrey.Applications.FileParsing.Ini

Specialized file parsing library for INI configuration files. Built on FileParsing framework with automatic parsing, reactive updates, and file browsing integration. Features auto-load support, observable patterns, and seamless integration with Oakrey.Files INI reader.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0 58 11/13/2026
4.0.1 170 9/18/2026
4.0.0 219 7/13/2026
3.0.1 224 5/21/2026
3.0.0 200 3/13/2026
2.1.0 182 1/20/2026
2.0.0 373 11/13/2025
1.1.0 267 10/30/2025
1.0.1 259 9/26/2025
1.0.0 403 4/16/2025