Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Seeking Alternative to COPY FILE Command
Message
De
28/11/2000 02:57:42
Walter Meester
HoogkarspelPays-Bas
 
 
À
27/11/2000 20:42:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00444304
Message ID:
00446049
Vues:
34
Hi charles,

>Forgive me for being dense, but I still don't understand how you get long field names with the COPY TO command (since one is copying to free tables, no?). I have never been successful doing this. Am I missing something?

The trick is that I don't use the COPY TO command, but the CopyFile API. The CopyFile API, like the DOS COPY command, creates an exact duplicate of the database files (or any other files for that matter).

The problem with this approach is that when some user is modifying a table that is beeing copied, you may end up with either a corrupte table or a inconsistent database (loss of RI integrity). Therefore it might be handy to FLOCK the files at forehand (before using the CopyFile API), for example this might work for you:
IF !DIRECTORY("dataexport")
	MD dataexport
ENDIF

=ADIR(aFiles,"data\*.*")

DECLARE INTEGER CopyFile IN KERNEL32.DLL ;
   STRING @SourceFileName, ;
   STRING @DestFileName, ;
   INTEGER bFailIfExists

nSucces=0
=ADIR(aDbfs,"data\*.dbf")
FOR nT = 1 TO ALEN(aDbfs,1)
	SELECT 0
	USE ("data\"+aDbfs[nT,1]) AGAIN ALIAS ("__Table"+ALLTRIM(STR(nT)))
	nSucces=IIF(FLOCK(),1,0)
	IF nSucces=0
		EXIT
	ENDIF
ENDFOR

IF nSucces # 0
	FOR nT = 1 TO ALEN(aFiles,1)
		nSucces=CopyFile(SYS(5)+SYS(2003)+"\data\"+aFiles[nT,1],SYS(5)+SYS(2003)+"\dataexport\"+aFiles[nT,1],0)
		THISFORM.Text1.Value=aFiles[nT,1]
		IF nSucces = 0
			wait window aFiles[nT,1]
			exit
		ENDIF
	ENDFOR
ENDIF

IF nSucces = 0
	MESSAGEBOX("Een of meerdere bestanden konden niet gekopieerd worden",0,_VFP.Caption)
ELSE
	MESSAGEBOX("De export is voltooid.",36,_VFP.Caption)
ENDIF
Good luck,

Walter,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform