Revertir la generación de PDF en C#

I have written a C# function for 1) Generating PDF file into folder in its own solution. 2) making entry into SQL database with PDF file name & its size.

Quiero,

=> Rollback the PDF generation if the Data insertion into the Database fails.
   Because the File may not be used in future.

i.e. If someone stops the Process in the middle before the entry made into Database then for that situation I have to use precaution like this.

Because the File may not be used in future.

Is it possible to rollback the Generation of PDF?

preguntado el 12 de febrero de 14 a las 05:02

2 Respuestas

The simple solution is to delete the generate Pdf file when the database update fails. Deleting a file is fairly easy File.Delete(fileName);

Respondido 12 Feb 14, 06:02

You can use transactional file manager library given by codeplex along with transactionscope to achieve your task. Aquí is the link as to how you can implement transactional file manager along with database transaction.

Also the newer versions of windows has something called TxF (Transactional NTFS) which you can use. Check out the link aquí. Not very sure if this will address your problem but you can definitely try.

Espero que esto ayude.

Respondido 12 Feb 14, 06:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.