Checking For File being open

This forum is for eXpress++ general support.
Post Reply
Message
Author
omni
Posts: 554
Joined: Thu Jan 28, 2010 9:34 am

Checking For File being open

#1 Post by omni »

Roger,

This is not for a dbf, just to clarify.

We import images, some users importing hundreds at a time to attach to different data files. Recently at one of our sites the import is crashing because somebody on the other end has one of the image files open. We fail in copying the file to the image save folder, and also will eventually fail when attempting to erase it when completed.
Is there a method to check to see if the file can be copied and just skip it until the next import? Not exactly an express or alaska quesiton, but thought somebody else may have run across this type of issue. Maybe some sort of if(copy) or something that already exists.

Thanks,

Fred
Omni

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Checking For File being open

#2 Post by Tom »

Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Checking For File being open

#3 Post by bwolfsohn »

if erasing, you can also use fexists to check if the file is still there..

on copying, you can compare date/times/sizes after the copy
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

omni
Posts: 554
Joined: Thu Jan 28, 2010 9:34 am

Re: Checking For File being open

#4 Post by omni »

Rogers bit of code at the end is what was needed. Worked perfect.

Thanks

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Checking For File being open

#5 Post by Eugene Lutsenko »

When Roger is such a decision, Kotra works well. It may be suitable in this case?

Code: Select all

**********************************************************
******** Проверка, открыт файл или нет (от Роджера Доннея)
**********************************************************
FUNCTION IsFileOpened( cFileName )

*#include "fileio.ch"
LOCAL lStatus := .F.       // Файл cFileName закрыт
LOCAL nHandle := FOpen( cFileName, FO_READWRITE+FO_DENYWRITE )

IF nHandle <= 0
  lStatus := .T.           // Файл cFileName открыт или его нет
ELSE
  FClose(nHandle)
ENDIF

RETURN lStatus
And Tom advised to determine whether or not a file is opened on the fact of the existence of a temporary file, which is generated when opening and udalat at closing.

Post Reply