Jump to content

File in use


Recommended Posts

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

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...