Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using copy file 3

Status
Not open for further replies.

kraus

MIS
Oct 16, 2000
23
US
i have vfp 6.0 on a ME machine. have most recent service pack

i'm trying to use a temporary dbf with cdx and fpt files. the dbf is copied from the server (mapped drive) to the local hard drive using the 'copy file' command. the user makes changes to the table and upon exit the dbf (with the cdx and fpt files)is copied back to the server using the 'copy file' command once again.

the changes are made to the table on the local drive, i've checked. but, when the table is copied back to the server and then the table is copied back to the local drive to open again, the changes aren't there. there is no errors. i just have the computer overwriting the files each time it copies. this is maddening..why can't it just write over the files...i've looked over my code for three days...i just won't do what i'm telling it to do.
 
First idea, if there is table buffering enabled on the tables that you are making changes to then you need to issue:
=TABLEUPDATE(.T.)

in order for your changes to be truly saved to the disk...just because you see the changes in your application doesn't mean that you are looking at the information on the disk...you may in fact be looking at buffered data that only exists in RAM.

Next idea, if the copy is happening right after you make changes to the tables there may something going on with VFP not actually flushing the changes to the disk (very unlikely, but it may be possible I think). Issue the command:

FLUSH

before doing the copy just to make sure that the information has been written to the disk.

Final idea, (and maybe this is the first one I would try)dispense with the copy file for a moment and manually copy the files out to the server yourself (using windows explorer or something) and see if when you bring them back down they are what you expected. This will be able to rule out a lot of things for you (user permissions, other code in your system, buffering mode, etc.) If not then the problem is not with the Copy File command but somewhere else...if they are not what you expect then it is indeed the Copy File command that is somehow causing the problem. At that point I would maybe try an alternate way of copying the files... an API call maybe...and see if that has the ability to overwrite the files.

If all of these methods fail or you have anymore questions regarding them let me know, I'll be around.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
kraus

Slighthaze has suggested you consider using a WinAPI call as a substitute for the native COPY FILE command.

The WinAPI call CopyFile() has the advantage of returning a value indicating the success or otherwise of the operation.

DECLARE INTEGER CopyFile IN Kernel32 ;
[tab]STRING lpExistingFileName ,;
[tab]STRING lpNewFileName ,;
[tab]INTEGER bFailIfExists

lnRetVal = CopyFile([C:\MyApp\table1.dbf] ;
[tab]+ CHR(0) ,;
[tab][D:\backup\table1.dbf] ;
[tab]+ CHR(0) ,;
[tab]0)

IF lnRetVal = 0 && Copy Failed
[tab]MESSAGEBOX([Error!])
ENDI

If the third parameter is set to false and the new file already exists, the function overwrites the existing file and succeeds.

It also has the advantage, VFP tables being an exception, of being able to copy files that are in use by another Windows application.

It has the disadvantage, for obvious reasons, that it will not accept wildcards.

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Chris,

Nice follow-up...Star!

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
It has the disadvantage, for obvious reasons, that it will not accept wildcards.

Is there another way to use the api call or some other method that will allow coping of multiple files with wildcards to the mapped drive on a backup machine?
thanks
wjwjr
 
Could you not just use:

copy to \\serverName\my.dbf CDX and eliminate the copy file command and the buffering issue?


Steve Bowman
steve.bowman@ultraex.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top