Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting Locked Files
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Detecting Locked Files
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01059899
Message ID:
01059899
Views:
60
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:
    Those who need closure
Next
Reply
Map
View

Click here to load this message in the networking platform