Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is file open?
Message
De
03/03/2006 15:21:17
 
 
À
03/03/2006 12:10:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01101298
Message ID:
01101375
Vues:
10
>I am converting a report to PDF. Is there a way to find out when the file is completely done?
>
>Thanks

Mark,
I create PDF files from reports and then email them as attachments. Here is a prg I use to make sure the pdf is ready (I check for the file and then make sure the byte count is not zero):
* WaitForFileToWrite.prg	-	Wait for file to finish getting written to
*
* This prg was created to address a problem with pdf email attachments.  I believe
* that the pdfs weren't finished being written to before blat email them out... result was
* email with no attachment.  This prg will delay the system until a non-zero byte count
* is established.
*
* V1.0	10-Jun-03	EP	-Original
*
*/* TO DO: ADD ERROR HANDLING SHOULD THIS PRG FAIL!
LPARAMETERS m.lcAttachment
LOCAL m.lnAtt
LOCAL ARRAY laAtt[1]
LOCAL m.ltStart, m.llExit
m.ltStart = DATETIME()
m.llExit = .f.

DO WHILE NOT m.llExit
	IF FILE(m.lcAttachment)
* file exists, loop until file size is not zero or 5 minutes passes
		m.ltStart = DATETIME()
		DO WHILE .T.
* exit if 2 minutes have passed
			IF DATETIME() - m.ltStart > 120
				m.llExit = .t.
				EXIT
			ENDIF
* get adir() of the attachment
			m.lnAtt = ADIR(laAtt, m.lcAttachment)
			IF m.lnAtt > 0
* array exists
				IF laAtt[2] > 0
* file size is not zero!  OK to leave!
					m.llExit = .t.
					EXIT
				ENDIF
			ENDIF
		ENDDO
	ELSE
* loop for 2 minutes if file not found
		IF DATETIME() - m.ltStart > 120
			m.llExit = .t.
			EXIT
		ENDIF
	ENDIF
ENDDO
RETURN
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform