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
<PackageReference Include="Oakrey.Applications.Files.Abstractions" Version="6.0.0" />
<PackageVersion Include="Oakrey.Applications.Files.Abstractions" Version="6.0.0" />
<PackageReference Include="Oakrey.Applications.Files.Abstractions" />
paket add Oakrey.Applications.Files.Abstractions --version 6.0.0
#r "nuget: Oakrey.Applications.Files.Abstractions, 6.0.0"
#:package Oakrey.Applications.Files.Abstractions@6.0.0
#addin nuget:?package=Oakrey.Applications.Files.Abstractions&version=6.0.0
#tool nuget:?package=Oakrey.Applications.Files.Abstractions&version=6.0.0
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
IFileServiceinterface. No implementation, logging, or telemetry code is included. - The concrete implementation (
FileService) is inOakrey.Applications.Filesand adds thread-safe async access viaSemaphoreSlim, structured logging viaOakrey.Log, and OpenTelemetry activity spans viaOakrey.Telemetry. - Both packages share the
Oakrey.Applications.Filesroot namespace.
License
MIT � Copyright � Oakrey 2016-present
| 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
- 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.