Welcome! Log In Create A New Profile

Advanced

Error on copying to an external file

Posted by Joel 
Joel
Error on copying to an external file
April 07, 2009 03:07PM
Each time I make a change to a file, I want to copy it to the server. I can do it the first time, but then I get an error that the file is locked, or I don't have permissions, etc. I'm guessing I have to do something to "release" the external file after copying - anyone know how to do that? Here's the code...

PROCEDURE SaveListItemsFile()
sMyDirectory is string = "C:\Program Files\HF Server\BDD\MAFASW\"+gpsStudio+"\"
sFilestoCopy is string = sMyDirectory+"HFListItems.*"
sDestinationDirectory is string = "C:\Program Files\HF Server\BDD\MAFASW\"

IF fDirectoryExist(sMyDirectory) THEN
Info("The directory "+ sMyDirectory +" exists on the disk")
Info(sFilestoCopy,sDestinationDirectory)
sCopyResult is string = fCopyFile(sFilestoCopy,sDestinationDirectory)
IF sCopyResult = True THEN
Info("Copy Completed")
ELSE
Info("Copy Failed")
END

END

thanks!
Joel
Re: Error on copying to an external file
April 07, 2009 03:26PM
Also - I'd rather not copy the file each time it's changed - I'd rather just check once before the system shuts down and copy it if it's changed. Where would I put code like that - that would always be run no matter if someone logged out or just shut the browser?
Jeff Graham
Re: Error on copying to an external file
April 07, 2009 10:03PM
Hi Joel,

If you do not close the file before copying it, that may cause it to be locked after it is copied. Make sure you have closed it before copying. Also there is an fUnlock but I have not used it. The other thing we do is use fRename to make a backup of the destination file and then you are not overwriting. You can use fDelete for previous backups or generate a unique name and delete the old ones after a certain time. We have code for that if you are interested.

See fDate to check if a file has been modified in your project logout code.Check out "Duplicate finder" in WinDev solutions for CRC comparisons.

Cheers,
Jeff
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: