none
determine when file will be free which used by another process c#

    Diskusi Umum

  • Hi,

    Is there any way  to determine when the file will be free to delete which is used by another process c#.

    Thanks.

    13 Maret 2012 7:05

Semua Balasan

  • 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.


    • Diedit oleh cheong00 13 Maret 2012 9:50
    13 Maret 2012 7:59
  • I 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.
    13 Maret 2012 8:01
  • 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.

    13 Maret 2012 8:06