Sign in to follow this  
Followers 0
TanBandradi

File in use

3 posts in this topic

Dear AutoIt Forum,

How to detect if a file is in use? the file is not only limited to .exe file extension, but also .tmp and etc. I need this to delete temporary files in @TempDir folder, but the deletion process takes longer if the deletion attempts to the file that in use.

Thank you in advance,

Tan

Share this post


Link to post
Share on other sites



Well the best i can come up with is to do this

Func DelIFNotInUse($filename)
    $file = FileOpen($filename, 2)
    If $file <> -1 Then
        FileClose($file)
        FileDelete($filename)
    EndIf
EndFunc

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Yes, this is the best solution, thanks!

Tan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0