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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backing up membership system 2

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
In my project development I have a backup routine on the F12 key which I call when needed.

Essentially it uses

<code>

fso= CREATEOBJECT ('Scripting.FileSystemObject')
fso.CopyFolder (lcDevDir, lcBackupDir)
fso = null
?'Finished Successfully'

</code>

Now I'm trying to use the same code on a button on a form after selection of a suitable folder.

All works OK until the copyfolder line when I get a COM error.

OLE error code 0x800a004c: Unknown COM status code.

Am I trying to use the code in the wrong place - why the error and how do I get past it please.

Thanks

GenDEV
 
In which line, what does AERROR(() return?

I assume not in fso = CREATEOBJECT(..), that works anywhere.
Check if lcDevDir, lcBackupDir are really fll paths.

Remember: nothing but foxpro has an idea of the current directory of your application, if you pass a relative path towards COM it errors.
The need for realtive paths is seldom, I prefer absolute paths wherever I can, even internally within the foxpro process.

Last Not Least I get the error by passing on a wrong path, so most probably that is the reason.

Prechecking with DIRECTORY() will not help, as foxpro will return .t. for relative paths.

Bye, Olaf.
 
GedDev,

In addition to what Olaf said, have you checked that lcDevDir and lcBackupDir contain what you expect? These are presumably local variables, but your code doesn't show any values being assigned to them.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike and Olaf,

I should have shown you all of the code - sorry

<code>

LOCAL lcBackupDir,lcCurrDir
lcCurrDir = CURDIR()
lcBackupDir= seldirdlg()

CLOSE ALL DATABASES

fso= CREATEOBJECT ('Scripting.FileSystemObject')
fso.CopyFolder (lcCurrDir, lcBackupDir)
fso = null

Messagebox('Finished Successfully!',48,'BMWOCSA')

QUIT
</code>

As I said before it crashes at the so.CopyFolder (lcCurrDir, lcBackupDir) line.

Looking at the paths in the debugger they look correct.

REgards

GenDev
 
GenDev,

I've tried running your code. In my tests, I get the same error if the backup directory doesn't already exist. But if the directory does exist, then the source directory is successfully copied to the backup.

So, you could do this: First, use DIRECTORY() to check to see if the backup directory exists. If it doesn't, use MKDIR to create it. Then go ahead and do the copying.

Perhaps you could give that a try and report back.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
BEsides what Mike says, curdir() is what I warned about: A relative path. Fullpath(CurDir()) or SYS(5)+SYS(2003) give you the current directory as full path. CopyFolder() needs both paths to be fully qualified and existing.

Bye, Olaf.
 
Olaf,

Yes I did spot that after my post and added sys(5) before curdir() with no luck then tried your SYS(5)+SYS(2003).

And it worked - thanks very much.

Mike,

The lcBackupDir= seldirdlg() sort of ensures an existing folder as a selection is made from the list of current folders or a new one can be created within the function.

Thanks to both

GenDEv
 
CurDir() differs in a last backslash from sys(2003), different functions need the final backslash, others will rather not take it, trailing spaces may also hurt. You alsways have to make some tests with the component you're using.

Bye, Olaf.
 
GenDev,

Glad to see it's working.

Just one other small point:

When you post program code in this forum, you need to use square brackets to delimit the tags, not angle brackets. In other words, you need something like this:

Code:
[ignore]
[code]
 ... your code here ...
[/ignore]
[/code]

Rather than:

Code:
<code>
 ... your code here ...
</code>

I think you'll find the result is easier to read.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Simply click on the "Process TGML" link right of it's checkbox and all "tekumseh group markup language" tags will be explained in a new window (unless your browser blocks popups and you don't allow them).

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top