All Projects → chinhdo → txFileManager

chinhdo / txFileManager

Licence: MIT License
.NET Transactional File Manager is a .NET Standard library that allows you to enlist file operations (file/folder copies, writes, deletes, appends, etc.) in distributed transactions.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to txFileManager

WebDavClient
Asynchronous cross-platform WebDAV client for .NET Core
Stars: ✭ 98 (+34.25%)
Mutual labels:  dotnet-standard
Okanshi
mvno.github.io/okanshi
Stars: ✭ 14 (-80.82%)
Mutual labels:  dotnet-standard
cv4pve-api-dotnet
Proxmox VE Client API .Net C#
Stars: ✭ 25 (-65.75%)
Mutual labels:  dotnet-standard
Workday.WebServices
Workday API clients
Stars: ✭ 18 (-75.34%)
Mutual labels:  dotnet-standard
Mutatio
Visual Studio for Mac add-in/extension for converting old PCLs to .NET Standard 2.0 targeting projects automatically.
Stars: ✭ 27 (-63.01%)
Mutual labels:  dotnet-standard
oryx
.NET Cross platform and highly composable middleware for building web request handlers in F#
Stars: ✭ 178 (+143.84%)
Mutual labels:  dotnet-standard
dapr-sidekick-dotnet
Dapr Sidekick for .NET - a lightweight lifetime management component for Dapr
Stars: ✭ 113 (+54.79%)
Mutual labels:  dotnet-standard
pastebin-csharp
API client for Pastebin in C#
Stars: ✭ 25 (-65.75%)
Mutual labels:  dotnet-standard
barcoder
Lightweight Barcode Encoding Library for .NET Framework, .NET Standard and .NET Core.
Stars: ✭ 76 (+4.11%)
Mutual labels:  dotnet-standard
django-transactions-tutorial
django-transactions-tutorial 基本教學 - 了解 transactions 概念 📝
Stars: ✭ 33 (-54.79%)
Mutual labels:  transactions
HardwareInformation
.NET Standard Cross-Platform Hardware Information Gatherer
Stars: ✭ 37 (-49.32%)
Mutual labels:  dotnet-standard
Harbour-MVP
Building a decentralised p2p meta-tx relayer network [MVP] Codename: Harbour ## We solved this problem: https://medium.com/tabookey/1-800-ethereum-gas-stations-network-for-toll-free-transactions-4bbfc03a0a56
Stars: ✭ 31 (-57.53%)
Mutual labels:  transactions
broadlink-dotnet
.Net standard library for Broadlink devices
Stars: ✭ 13 (-82.19%)
Mutual labels:  dotnet-standard
chatbase-dotnet
Integrate your DotNet application with Chatbase!
Stars: ✭ 16 (-78.08%)
Mutual labels:  dotnet-standard
cognite-sdk-dotnet
.NET SDK for Cognite Data Fusion (CDF)
Stars: ✭ 14 (-80.82%)
Mutual labels:  dotnet-standard
chess
Chess (game)(♟) built in C# and ASCII art.
Stars: ✭ 20 (-72.6%)
Mutual labels:  dotnet-standard
pem-utils
Managed .NET (C#) utility library for working with PEM files with DER/ASN.1 encoding
Stars: ✭ 62 (-15.07%)
Mutual labels:  dotnet-standard
Resume-Ranker
Keyword-based resume ranker
Stars: ✭ 21 (-71.23%)
Mutual labels:  file-io
NCalc2
GitHub clone of NCalc from http://ncalc.codeplex.com/
Stars: ✭ 97 (+32.88%)
Mutual labels:  dotnet-standard
Slugify
Simple Slug / Clean URL generator helper for Microsoft .NET framework / .NET Standard.
Stars: ✭ 53 (-27.4%)
Mutual labels:  dotnet-standard

Transactional File Manager is a .NET Standard 2.0 library that supports including file system operations such as file copy, move, delete, append, etc. in a transaction. It's an implementation of System.Transaction.IEnlistmentNotification.

This library allows you to wrap file system operations in transactions like this:

// Wrap a file copy and a database insert in the same transaction
IFileManager fm = new TxFileManager();
using (TransactionScope scope1 = new TransactionScope())
{
    // Copy a file
    fm.Copy(srcFileName, destFileName);

    // Insert a database record
    db.ExecuteNonQuery(insertSql);

    scope1.Complete();
} 

Current features

Support the following file operations in transactions:

  • AppendAllText: Appends the specified string the file, creating the file if it doesn't already exist.
  • Copy: Copy a file to another file.
  • Delete: Delete a file.
  • Move: Move a file.
  • CreateDirectory: Create a directory.
  • DeleteDirectory: Delete a directory.
  • MoveDirectory: Move a directory.
  • Snapshot: Take a snapshot of the specified file. The snapshot is used to rollback the file later if needed.
  • WriteAllBytes: Write the specified bytes to the file.
  • WriteAllText: Write the specified text content to the file.

If you have any suggestions for enhancements or bug reports please use the Issues list. Better yet, if possible join this project and contribute.

This library is available as a NuGet package.

This started out as a blog post. It was hosted on CodePlex and migrated to GitHub in 3/2020.

Additional contributors: @gvas, AirBreather.

Quick Start

  1. Add a reference to TxFileManager
dotnet add package TxFileManager
  1. Start writing code
IFileManager fm = new TxFileManager();
using (TransactionScope scope1 = new TransactionScope())
{
    // Copy a file
    fm.Copy(srcFileName, destFileName);

    scope1.Complete();
} 

Frequently Asked Questions

How do I reference this library?

The recommended method is to add a NuGet reference:

dotnet add package TxFileManager

Or Use Visual Studio's Manage NuGet Packages to add. Search for "TxFileManager".

Can I reuse instances of TxFileManager?

It's not expensive to create new instances of TxFileManager as needed. There's a bit of overhead (like creating instances of any small class) but not much.

On the other hand, it's totally safe to re-use the same instance for multiple transactions, even nested transactions.

Is TxFileManager Thread Safe?

Yes - it's been tested for that.

Which IsolationLevel's are supported?

Regardless of the specified IsolationLevel, the effective IsolationLevel is ReadUncommitted.

How does TxFileManager work?

See Chinh's blog post: Include File Operations in Your Transactions Today with IEnlistmentNotification

Where are temporary files/directories kept?

By default, the path returned by Path.GetTempPath() is used to keep temporary files/directories used by TxFileManager. However, you can override that and have TxFileManager use another temp path:

IFileManager fm = new TxFileManager(myTempPath);

How do I contribute to the project?

  • Fork the repo
  • Create a branch such as my-new-feature
  • Make your change/fix and associated unit tests and commit
  • Run the tests (dotnet test)
  • Open a Pull Request (PR) to the "master" branch

Notes: A release branch will be created out of the master branch when a release is made. The master branch will contain the latest features being added/tested for the next release.

Nuget Releases

Version 1.4 (released 3/2020)

  • Add support for custom temp paths to address issues with file/dir operations accross filesystems
  • Fix for resource leak in TxFileManager._txEnlistment
  • Target .NET Standard 2.0
  • Additional testing for .NET Core on Ubuntu
  • Additional stress testing both on Windows and Ubuntu
  • Created Github workflow to automatically build/test on ubuntu
  • Added FxCop static analysis

Version 1.5.0.1 (released 7/21/2021)

Please suggest your features using the Issues list.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].