Alternatives to using Transactional NTFS

纵饮孤独 提交于 2019-12-01 06:33:08

Give a try to .NET Transactional File Manager. It is fairly simple to use it safely. The following example from the page shows the way. It even looks like the author is responsive and is able to extend the library with new useful features.

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

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

    scope1.Complete();
} 

In case you are interested in your own transactional manager, be sure you check out this article. If you carefully examine the above mentioned library, you will find that it is implemented right this way.

From the link:

As a result, Microsoft is considering deprecating TxF APIs

It isn't dead yet! I don't know why they would remove an atomic file system API for Windows, even if it isn't largely supported yet. There should be a .NET BCL for ease of use leveraging TxF for starters. TxF style support for network copies would also be awesome.

If anything, Microsoft should be improving the API!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!