-1

I have 3 xml file to be written to a folder for client. while writing the 2 files got written perfectly but 3rd file failed. what are the ways by which I can prevent the client to open any file or all the files got deleted or locked if anything failed?

Akhire
  • 1
  • 1

1 Answers1

0

If your application has delete privileges on the system, keep a record of the filenames to the files you're writing. If a file fails for whatever reason, go through the list of file names and delete the files from the directory. A simple string list with a for loop should do it.

Thecor
  • 118
  • 1
  • 10
  • Can we use transaction in writing files? if anything file writing failed, I can rollback it. How can we use transactions? – Akhire Jun 14 '16 at 06:07
  • .NET does have a library called Transactional File Manager, but I haven't used it for VB. It will do what you're looking for in C#, but not all .NET libraries play well with both languages. – Thecor Jun 14 '16 at 06:19
  • Best alternative would be to create you're own transaction with a try/catch and a string list of the filenames. – Thecor Jun 14 '16 at 13:44