Tuesday, March 13, 2012 7:05 AM
Is there any way to determine when the file will be free to delete which is used by another process c#.
Tuesday, March 13, 2012 7:59 AM
AFAIK, there are only two ways if you need to do so in Vista or earlier versions of Windows:
1) Try to delete it every 5 minutes. If it can be deleted, it will be deleted.
2) Try adding a startup task in scheduler/registry, and delete the file at next boot time. Most likely it will not be locked.
Methods such as scanning the processes for opened file handles won't reliably work as your application have no guarantee that it is access to all system process... even when it's running as local administrator.
Please also read a blog post related here.
- Edited by cheong00 Tuesday, March 13, 2012 9:50 AM
Tuesday, March 13, 2012 8:01 AMI think either the process which has exclusively captured the file should inform other apps (for example by sending a signal using a kernel synchronization construct such as Mutex) or the waiting process should use a polling mechanism and periodically check to see if the file is freed or not.
Tuesday, March 13, 2012 8:06 AM
From the programming pt of view, i will be continue the loop to check whether the file is free by another process or not. As the system free the file, my loop will insert into to delete the same.
So i need some idea about it that how to wait.