Jump to content

Recommended Posts

Posted (edited)

Hi AutoIt Gurus,

I have the following problem:

An external program creates a PDF-file (~900KB) in a directory. My script checks for this file and when it exists it moves the file do another directory with a different name. Now I have a reproducible situation where I get an error from FileMove. When I wait a few seconds after I detect the file the script runs fine.

I think FileExists tells me "file found" even when the file is still being written by the other application. Therefore the error when moving the file.

What is the best way to tell that the file has been closed by the other application?

Thanks for your help in advance!

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 7/17/2009 at 1:43 PM, 'water said:

Hi AutoIt Gurus,

I have the following problem:

An external program creates a PDF-file (~900KB) in a directory. My script checks for this file and when it exists it moves the file do another directory with a different name. Now I have a reproducible situation where I get an error from FileMove. When I wait a few seconds after I detect the file the script runs fine.

I think FileExists tells me "file found" even when the file is still being written by the other application. Therefore the error when moving the file.

What is the best way to tell that the file has been closed by the other application?

Thanks for your help in advance!

You can't move a file that is in use (open) by another program. If you know the size of the file then you wight want to check with FileGetSize() instead of FileExists(). Or if the external program closes after creating the file then use ProcessExists() to see if it's moveable yet or not. There are several methods of checking for what you need.

George

  Reveal hidden contents
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!"

Posted (edited)

Thanks for your reply!

Unfortunately I don't know the size of the file. It was just an example and the size varies.

The external program is running on another machine (a server that converts print files to pdf) so I can't check the process.

I was thinking of some code to check wether someone else has the file open for reading or writing.

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Thanks a lot for your replies!

I'll try the FileOpen approach.

My UDFs and Tutorials:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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