随着TransactionScope的文件在C# [英] TransactionScope With Files In C#

查看:155
本文介绍了随着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个文件,并发生异常九号文件,所有的previous 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?

推荐答案

您正在寻找的事务NTFS ,通过Windows Vista中引入的。

You're looking for Transactional NTFS, introduced by Windows Vista.

这里是一个托管包装

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

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