How to check if file is busy/locked?
Posted: 17 Dec 2009 13:25
Hi i'm having trouble finding a clean solution that checks if a file is busy/locked.
I know one way would be try to rename the file, if it suceeds, the file is not locked and you rename the file back to it's original filename.
I think it's a bit nasty, alltho it works in most cases, so i would like to have something more clean!
I had anohter solution, using a compiled 3rd party exe, called fsum.exe (SlavaSoft), it creates checksums for files, and the good thing was that this tool returns "DENIED" if the file is busy/locked. The "not so good" was that, because of the way fsum.exe works, large files could take up to seconds to read.
So, does anyone found a clean way to check if a file is busy?
I know one way would be try to rename the file, if it suceeds, the file is not locked and you rename the file back to it's original filename.
I think it's a bit nasty, alltho it works in most cases, so i would like to have something more clean!
I had anohter solution, using a compiled 3rd party exe, called fsum.exe (SlavaSoft), it creates checksums for files, and the good thing was that this tool returns "DENIED" if the file is busy/locked. The "not so good" was that, because of the way fsum.exe works, large files could take up to seconds to read.
So, does anyone found a clean way to check if a file is busy?