TransactionScope与C#中的文件 [英] TransactionScope With Files In C#

查看:187
本文介绍了TransactionScope与C#中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用TransactionScope来处理数据库,感觉很好。我正在寻找的是:

I've been using TransactionScope to work with the database and it feels nice. What I'm looking for is the following:

using(var scope=new TransactionScope())
{               
    // Do something with a few files...
    scope.Complete();
}

但显然这不行 - 如果有20个文件,第9个文件发生异常,所有以前的8个都保留更改,其余的不变 - 不执行回滚。那么,为文件实现范围行为的最佳方式是什么?

but obviously this doesn't work -- if there are 20 files, and an exception occurs on the 9th file, all previous 8 remain changed and the rest unchanged -- no rollback is performed. So, what would be the best way to implement a scope-like behavior for files?

我希望有一个简单的答案,但如果没有,你能不能给我几个指针,或指向一个相关文章?

I'm hoping there is a simple answer, but if not, could you just give me a few pointers, or point me to an related article?

推荐答案

你正在寻找 Windows Vista引入的事务性NTFS

这是一个托管包装

这篇关于TransactionScope与C#中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆