Aloe.Utils.SafeIO 1.0.0

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

Aloe.Utils.SafeIO

Aloe.Utils.SafeIO is a lightweight and easy-to-use library for safe file operations. It can be used in applications that require file reading, writing, and manipulation.

Key Features

  • Safe File Deletion
    • Supports both synchronous and asynchronous operations
    • Configurable timeout and retry intervals
    • Proper handling of file lock states
  • Safe Directory Deletion
    • Supports recursive deletion
    • Supports both synchronous and asynchronous operations
    • Configurable timeout and retry intervals
  • Operation cancellation using cancellation tokens
  • Optimized exception handling

Supported Environments

  • .NET 9 and later

Installation

Install via NuGet Package Manager:

Install-Package Aloe.Utils.SafeIO

Or using .NET CLI:

dotnet add package Aloe.Utils.SafeIO

Usage Examples

Safe File Deletion

using Aloe.Utils.SafeIO;

// Synchronous version
SafeFile.Delete(
    "example.txt",
    timeout: TimeSpan.FromSeconds(30),
    retryInterval: TimeSpan.FromMilliseconds(100)
);

// Asynchronous version
await SafeFile.DeleteAsync(
    "example.txt",
    timeout: TimeSpan.FromSeconds(30),
    retryInterval: TimeSpan.FromMilliseconds(100),
    ct: cancellationToken
);

Safe Directory Deletion

using Aloe.Utils.SafeIO;

// Synchronous version
SafeDirectory.Delete(
    "example-directory",
    timeout: TimeSpan.FromSeconds(30),
    retryInterval: TimeSpan.FromMilliseconds(100)
);

// Asynchronous version
await SafeDirectory.DeleteAsync(
    "example-directory",
    timeout: TimeSpan.FromSeconds(30),
    retryInterval: TimeSpan.FromMilliseconds(100),
    ct: cancellationToken
);

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net9.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
1.0.0 131 5/22/2025