Oakrey.Applications.Files.Abstractions 6.0.0

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

Oakrey.Applications.Files.Abstractions

A .NET 10 library that defines the IFileService abstraction for file and directory operations. It contains no implementation code and carries no runtime dependencies, making it the correct reference for libraries and application layers that need file access without coupling to a concrete implementation.

Main features

Method Description
CreateFolder(folderName) Creates a directory at the given path
CreateSaveStream(fileName) Opens a writable FileStream for the given file
DeleteFile(fileName) Deletes a single file by path
DeleteFileOlderThan(path, timeSpan, extension, ct) Deletes files in a directory that are older than the given TimeSpan, filtered by extension
GetFilesPaths(folder, extension) Returns all file paths inside a directory tree matching the given extension
LoadFile(fileName) Reads file content as a string (synchronous)
LoadFileAsync(fileName, ct) Reads file content as a string (asynchronous, CancellationToken aware)
LoadFileStream(fileName) Opens a readable FileStream for the given file
SaveFile(fileName, value) Writes a string to a file, creating intermediate directories if needed

Architecture

classDiagram
    class IFileService {
        +CreateFolder(folderName)
        +CreateSaveStream(fileName) FileStream
        +DeleteFile(fileName)
        +DeleteFileOlderThan(path, timeSpan, extension, ct) Task
        +GetFilesPaths(folder, extension) string[]
        +LoadFile(fileName) string
        +LoadFileAsync(fileName, ct) Task~string~
        +LoadFileStream(fileName) FileStream
        +SaveFile(fileName, value)
    }

    class FileService {
        <<Oakrey.Applications.Files>>
    }

    IFileService <|.. FileService

The concrete implementation lives in the separate Oakrey.Applications.Files package. Consuming projects should reference only this abstractions package and register the implementation via the extension provided by Oakrey.Applications.Files.

Requirements

  • .NET 10 or later

Installation

dotnet add package Oakrey.Applications.Files.Abstractions

To also include the concrete implementation:

dotnet add package Oakrey.Applications.Files

Example usage

Registering the service

// In your composition root, reference Oakrey.Applications.Files for the extension method.
services.AddFilesService();

Consuming the abstraction

public sealed class ReportExporter
{
    private readonly IFileService _fileService;

    public ReportExporter(IFileService fileService)
    {
        _fileService = fileService;
    }

    public async Task ExportAsync(string path, string content, CancellationToken cancellationToken)
    {
        _fileService.CreateFolder(System.IO.Path.GetDirectoryName(path)!);
        _fileService.SaveFile(path, content);
    }

    public async Task<string> LoadAsync(string path, CancellationToken cancellationToken)
    {
        return await _fileService.LoadFileAsync(path, cancellationToken);
    }
}

Age-based cleanup

await _fileService.DeleteFileOlderThan(
    path: @"C:\Logs",
    timeSpan: TimeSpan.FromDays(30),
    extensionWithoutDot: "log",
    cancellationToken: cancellationToken);

Development notes

  • This package contains only the IFileService interface. No implementation, logging, or telemetry code is included.
  • The concrete implementation (FileService) is in Oakrey.Applications.Files and adds thread-safe async access via SemaphoreSlim, structured logging via Oakrey.Log, and OpenTelemetry activity spans via Oakrey.Telemetry.
  • Both packages share the Oakrey.Applications.Files root namespace.

License

MIT � Copyright � Oakrey 2016-present

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

Showing the top 5 NuGet packages that depend on Oakrey.Applications.Files.Abstractions:

Package Downloads
Oakrey.Applications.Settings

WPF-only (.NET 10 Windows) library providing ISettingsService with persistent and volatile typed key-value settings, SettingsBase for bindable ViewModelBase-derived settings classes, CallerMemberName key inference, built-in window bounds restore via RestoreBounds, and a one-call ConfigureSettingService DI extension.

Oakrey.Applications.Log

Integrates Oakrey logging into .NET WPF apps via IServiceCollection extensions: registers a WpfQueueLogger for real-time UI log visualization, a settings-persisted LogViewModel with log-level filtering, and a preloadable log file cleanup service with a 7-day retention policy.

Oakrey.Applications.Json

Provides IJsonService for stream-based JSON serialization and deserialization using System.Text.Json, with async CancellationToken support, batch directory load, IName-keyed batch save, and built-in logging and OpenTelemetry tracing via IFileService.

Oakrey.Applications.Files

Provides IFileService with synchronous and asynchronous file and directory operations including CRUD, stream access, and age-based deletion, with built-in logging and OpenTelemetry tracing.

Oakrey.Applications.Ohm.CAN

Service layer library for managing CAN bus hardware devices and channels. Provides device discovery, connection lifecycle management, reactive IObservable streams for received frames and status changes, per-channel transmit, USB hot-plug detection, and persistent JSON configuration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0 134 5/22/2026
3.0.3 130 5/22/2026