views:

43

answers:

1

I have a file and need to ensure it exist before inserting a row into the db. After i insert i need to use the PK as part of the filename and move it into another location.

How do i check if it exist then lock it so it cant be deleted until i can insert into the db then proceed to move the file without it being deleted upon releasing the lock?

also the file may be in use. I am thinking of copying the file into a safe location then moving that file away. In this case i need to copy a file that is being used for reading. How can i do the above steps safely?

Using .NET

A: 

You need Windows Vista with Transactional NTFS for that. It need some P/Invoke codes, see the "TxF from Managed Code" section for details.

For related questions, see this thread.

J-16 SDiZ