Filecopy solution...

D-Fresh

Registered User.
Local time
Today, 10:04
Joined
Jun 6, 2000
Messages
225
Does anyone know of a way to copy a database file that is currently open? The Filecopy command from VB returns an error when you use it on an open file.. but if you copy a file manually through windows if it's currently open, it will work. Any suggestions would be greatly appreciated. Thanks.

Doug
 
[cringe]
I hate doing things this way, but it might work...

...You could run a batch (.bat) command file that carries out the copy operation.

If you need it to be dynamic (i.e. to copy to a different location each time, you would need to generate the .bat file dynamically in code using Print# to put the correct file/path names in there.

This method is going to have a problem with long names though...
[/cringe]

Mike
 
A very interesting thought.... I definitely agree with you, bad way to do it, but desperate times call for desperate measures... Thanks for the reply.

Doug
 
I am not sure if this is a better way or not but it works.

Call Shell("xcopy C:\database.mdb D\database.mdb", 1)

I tried experimenting with the sendkeys to stop the prompt for file or folder but couldn't get it to work. Someone with WSH knowledge should be able to figure that part out though.

Anyway, I thought I would send this along just in case you were still looking for another way.
 
Thanks, but Mike's idea is actually going pretty well... I already am going through a loop of databases to backup... So I just overwrite a batchfile and run it in the loop.. I'm sure this probably eats up memory, but I only have about 20 databases or so and only run it about once a week... So I think it should be fine... Thanks again for all the help...

Doug
 
There is another way, which I use myself sometimes;

make a folder called 'flags' somewhere (Mine is on a network drive), create a little text file in the folder and call it 'default.txt'.

Now, suppose you have a database called 'Data' - you can set up this code that will run immediately it is opened:
Code:
FileCopy "g:\flags\default.txt", "g:\flags\DataOpen.txt"


then on close of the database, you can do:
Code:
Kill "g:\flags\DataOpen.txt"
FileCopy "g:\flags\default.txt", "g:\flags\DataDone.txt"

Then other applications can tell whether the database is open or not, more specifically, they can test whether it has just closed (because the 'done file will be there) and the backup can be done, so you can take the backup operation outside the main application.
of course, this can be done by just testing for the .ldb file, but the advantage of doing it my way is that (assuming your backup application tests for the presence of a 'done' file, then deletes the 'done' file after doing the backup), the application gets backed up every time it has finished being used.

HTH

Mike

[This message has been edited by Mike Gurman (edited 07-11-2001).]
 

Users who are viewing this thread

Back
Top Bottom