Oakrey.Files 3.0.0

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

Oakrey.Files

1. Overview

The Files project provides utilities for file naming and compression. It simplifies the generation of unique file names based on various policies and offers methods for compressing and decompressing files and byte arrays.

2. Feature

File Naming Utilities:

FileNameGenerator:

  • Generates file names based on policies like date-time, GUID, incremental, and user-defined formats.
  • Supports creating file paths by combining folder paths, file names, and extensions.

FileNameSource:

  • Encapsulates file naming parameters and provides methods to generate file names and paths dynamically.

FileNamingPolicy:

  • Enum defining supported naming policies (e.g., DateTime, GUID, Incremental).

Compression and Decompression:

ZipCompression:

  • Provides methods to compress and decompress byte arrays and files using GZip.

Thread-Safe Operations:

Ensures thread safety for file name generation using locks.

Extensibility:

Designed to support additional file naming policies and compression algorithms.

INI File Management

IniFile class:

  • Represents an INI configuration file with support for sections and key-value pairs.
  • Provides typed value accessors (GetBool, GetInt, GetDouble) with default value fallback.
  • Supports global (unnamed) section for entries outside named sections.
  • Offers both direct and try-pattern methods for safe value and section access.
  • Enables section and value manipulation (add, remove, check existence).
  • Thread-safe section and value lookups using normalized section names.

IniReader:

  • Loads INI files from disk with automatic encoding detection or custom encoding.
  • Parses INI content from StreamReader for flexible input sources.
  • Recognizes section headers ([SectionName]) and key-value pairs (key=value).
  • Supports comments starting with ; or #.
  • Handles whitespace normalization and empty lines.

IniWriter:

  • Saves INI files atomically using temp-file-and-replace pattern to prevent corruption.
  • Writes INI content to StreamWriter with optional global section control.
  • Supports custom text encoding (default UTF-8).
  • Ensures data integrity during save operations with automatic cleanup.

Extended INI File Management

IniExtendedFile class:

  • Full-featured INI file representation with complete comment and formatting preservation.
  • Supports preamble comments (comments before first section).
  • Maintains leading comments (blank lines and comments above sections/entries).
  • Supports inline comments on section headers and key-value entries.
  • Provides case-insensitive section and key lookups.
  • Offers both direct and try-pattern methods for safe value and section access.
  • Enables dynamic section and entry manipulation while preserving formatting.

IniReader (Extended):

  • Loads INI files with full preservation of comments, blank lines, and formatting.
  • Parses section headers with optional inline comments: [SectionName] ; comment.
  • Parses key-value pairs with inline comments: key=value ; comment.
  • Supports customizable comment start characters (default: ; and #).
  • Handles quoted values with embedded comment characters correctly.
  • Preserves document structure including preamble, leading comments, and blank lines.
  • Automatic encoding detection or custom encoding support.

IniExtendedWriter:

  • Writes INI files with complete formatting and comment preservation.
  • Atomic save operation using temp-file-and-replace pattern to prevent corruption.
  • Customizable key-value separator (default: =).
  • Customizable section header format (default: [{0}]).
  • Preserves all comments (preamble, leading, and inline).
  • Maintains blank lines for readability.
  • Ensures data integrity during save with automatic cleanup.

Supporting classes:

Entry:

  • Represents a key-value pair with optional inline comment.
  • Maintains collection of leading comments and blank lines.
  • Supports full formatting preservation during read/write cycles.

Section:

  • Represents a named section with its entries.
  • Supports optional inline comment on section header.
  • Maintains leading comments and blank lines before section declaration.
  • Provides FindEntry method for case-insensitive entry lookup.

Item, Comment, Blank:

  • Base types for representing INI file elements.
  • Comment - stores comment text including the comment character.
  • Blank - represents empty lines for formatting preservation.
  • Item - abstract base for all line types in INI file.

PendingItems:

  • Internal helper collection for managing comments and blanks during parsing.
  • Ensures proper association of comments with following sections/entries.

3. Installation

You can install the package via NuGet Package Manager, Package Manager Console or the .NET CLI.

NuGet Package Manager

  1. Open your project in Visual Studio.
  2. Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution....
  3. Search for Oakrey.Files and click Install.

.NET CLI

Run the following command in your terminal:

dotnet add package Oakrey.Files

Package Manager Console

Run the following command in your Package Manager Console:

Install-Package Oakrey.Files

4. Requirements

  • .NET 8 or higher

5. Project Information

6. Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the package.

7. License

This project is licensed under the MIT License. See the LICENSE file for details.

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 (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.Reporting

A .NET 10 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.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, thread-safe file writing, and integration with Oakrey.Telemetry and Oakrey.Log.

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
3.0.0 159 3/13/2026
2.1.0 152 1/20/2026
2.0.0 333 11/13/2025
1.1.0 233 10/30/2025
1.0.1 230 9/26/2025
1.0.0 370 4/16/2025