Jump to content

Open files


Recommended Posts

I am processing sets of files, some of which may be open. I want to skip these files and come back to them.

How can I determine if a file is open by another application?

Thanks in advance for any assistance.

Keep them listed in an array.

Attempt to open for write (append, not overwrite).

- If it fails, skip it.

- If it succeeds, process it and delete it from the array.

Repeat loop until the array is empty.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I am processing sets of files, some of which may be open. I want to skip these files and come back to them.

How can I determine if a file is open by another application?

Thanks in advance for any assistance.

Pretty much impossible.. I needed it myself and no matter what I tried I couldn' get anything to work in AutoIt, KiXtart or VBS. Asked on several forums and no one had an answer so I gave up on the idea.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I am still able to open the file for writing, even though the file is open in another application.

For example, I have a document open in Word. I can still open the file for writing with FileOpen("file", 1).

The file will change, so I want to wait for the file to be closed before working with it.

I appreciate the responses. I have searched quite a bit myself and not yet found a solution, but there has to be some way to do it.

Any other thoughts?

Link to comment
Share on other sites

There is an API called IFileIsInUse that appears to help with a GetUsage method, but there is an issue: It appears to be for Vista only, and requires some over-my-head .dll calls.

Maybe some help from the .DLL gurus...?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks for the responses, I think I have a solution.

PsaltyDS, your link led to a blog article that linked to a SysInternals Utility, Handle.exe, that does exactly what I need.

So the solution will be to run the Handle utility, with the name of the file as a parameter, to determine if any applications have it open.

Handle returns the application name and PID.

Link to comment
Share on other sites

a simple way is to attempt to move it, then move it back. If you can move it, it is available. If you can't, then something is accessing it.

That was my problem. I needed to move the files and If one was in use then the app that had the file open would have to be closed or a a handle to a file released. In one particular case it was my own app that had it open And I could use FileClose($File) all day but it wouldn't release that file.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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