how to rollback text

  • Thread starter Hakan Fatih YILDIRIM
  • Start date
H

Hakan Fatih YILDIRIM

Hi .net gurus,

Is there a way to rollback a text writen to a text file.I made a loop
that writes text in to a text file and if an exception occurs i want
it to rollback the writen texts?I tried Transactionscope but no
effects on writing texts.

Any ideas?
 
P

Peter Morris

01: Create a new file stream with a new filename
02: Copy the original text content into that stream
03: Write your changes
04: Close the stream
05: Use File.Copy(tempFileName, originalFileName, true) to overwrite the
original
06: Delete the temp file - using a finally block ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top