Skip to content

TxFileSystem is a transactional filesystem wrapper using the .NET Standard filesystem abstraction from System.IO.Abstractions

License

Notifications You must be signed in to change notification settings

eqxmedianl/EQXMedia.TxFileSystem

Repository files navigation

EQXMedia.TxFileSystem

EQXMedia.TxFileSystem is a transactional file system wrapper using the .NET file system abstraction from System.IO.Abstractions.

This file system wrapper supports transactional operations on:

  • Files,
  • Directories,
  • File streams.

About the Project

Build Status

.NETQuality Gate Status

Project Development

This library has been designed and implemented by Jarno Kamminga for EQX Media B.V., and published as an OpenSource project on GitHub.

Project Website

The project has a website of its own which can be found at https://txfilesystem.io/.

Library Documentation

The documentation of the library can be found at https://txfilesystem.io/docs/.

NuGet Package

A NuGet package is created of every EQXMedia.TxFileSystem release and can be installed to your .NET project using the NuGet Package Manager or dotnet command.

More information about the NuGet package can be found at NuGet.org:

https://www.nuget.org/packages/EQXMedia.TxFileSystem/

Installing the package

Package Manager

PS> Install-Package EQXMedia.TxFileSystem -Version 3.0.0-beta1

.NET CLI

$ dotnet add package EQXMedia.TxFileSystem --version 3.0.0-beta1

Package Reference

<PackageReference Include="EQXMedia.TxFileSystem" Version="3.0.0-beta1" />

Code Example

/**
*
* Because an error occurs inside the transaction scope, the creation of the file will not take place
* (or better said be rolled back):
*
* txFileSystem.File.Exists(@"C:\Users\JohnDoe\Documents\example.txt");
*
* Would simply return 'false' after execution of the below code.
*
**/

using System;
using System.IO.Abstractions;
using System.Transactions;
using EQXMedia.TxFileSystem;
    
using var transactionScope = TransactionScope();

var txFileSystem = new TxFileSystem(new FileSystem());
txFileSystem.File.Create(@"C:\Users\JohnDoe\Documents\example.txt");

throw new Exception("Error occurs after creating the file. Resulting in the creation to be rolled back.");

transactionScope.Complete();