Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wcf transactions

Status
Not open for further replies.

MirjanaBojanic123

Programmer
Jul 27, 2006
4
YU
I am using transactions in wcf, and I have one question. Transaction works fine when I work with database, it rollbacks all changes made in database if all commands are not completed.
But when I work with files, there is one problem. I want to copy few files in the computer, and to do some inputs into database. If all operations are not completed, I want to rollback all files that have been copied on the machine (In this case it would be deleting pasted files).
But, in mu case, operatins made on database are rollbaced, but files are still saved on machine, there is no mechanisam which automaclly deletes them.

Here is the code I use for transactions:

Using theScope As TransactionScope = New TransactionScope(TransactionScopeOption.Required)
Try
Dim tfc As New m_TransactedFile()
tfc.Copy("C:\Documents and Settings\Mirka\Desktop\From1.txt", "C:\Documents and Settings\Mirka\Desktop\To1.txt")

... (operations with database)

Dim tfc1 As New m_TransactedFile()
tfc1.Copy("C:\Documents and Settings\Mirka\Desktop\From2.txt", "C:\Documents and Settings\Mirka\Desktop\To2.txt")

theScope.Complete()

Catch ex As Exception
theScope.Dispose()
End Try
End Using


m_TransactedFile is user defined class, which Implements IEnlistmentNotification and ISinglePhaseNotification

If anyone knows about this problem, please write!
 
There is a transaction resource manager for the filesystem on Vista, but not earlier versions of Windows (XP, 2k, etc).

And even on Vista, there's no managed code to give you access to it.

So, you're out of luck, until Server 2008 comes out. Sorry.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top