Hi all,
What is the proper way to determine if a file is locked by another process?
I have a Windows service that handles File Create events from a File System Watcher. When a new file is created, it kicks off a new thread and goes back to sleep. The thread has a timer so it can sleep until the file has been completely written to disk. I am currently using the file size to determine when the file is no longer growing. That worked for another project where files were being created from an ftp download, but it doesn't work in this particular case. The files I'm dealing with now are being uploaded to a server as they are being recorded (streaming video). I think the file size is being reported as 0 until the file write is done (about 2 hours). Is there a way I can just ask the file if it's locked by another process? Then, I can just keep sleeping until the file is unlocked.
TIA,
Chad
_________________________________
There are 2 types of people in the world: