> I use a 'generic' prg for backup to my server which I modify when I change the location of a project.
>
> Sometimes I make a typo in the paths so I have introduced the directory command prior to the copy.
>
>
>
> #DEFINE SU_HOME 'mycurrentfolder'
>
> CLOSE ALL DATABASES
>
> public changes
> changes = ''
>
> && remove repeatable files
> delete file *.bak
> delete file *.err
> delete file *.dat
> delete file *.txt
> delete file *.fxp
> &&- add comment to file name in changes
> do form frmbackup
>
> *-- Getting the date as yyyymmdd is easy.
> lcToday = DTOS(DATE())
> *-- The time has colons between hours, minutes, and seconds.
> *-- These are illegal in a file name so change them to underscores.
> lcNow = CHRTRAN(TIME(), ':', '-')
> lcTimeStamp = lcToday + '_at_' + subst(lcNow,1,5)
> && project folder with prg,forms etc all in one folder
> lcDevDir = 'D:\DEV\_Foxpro\Projects\' + SU_HOME
> IF DIRECTORY(lcDevDir)
> *-- The backup folder must exist
> lcBackupDir = '\\Nasserver209\NASDATA\Backups\Test_Backup\' + SU_HOME + '\' + lcTimeStamp + ' ' + changes
> ENDIF
>
> ?lcBackupDir - to confirm on screen
> IF DIRECTORY(lcBackupDir)
> fso= CREATEOBJECT ('Scripting.FileSystemObject')
> fso.CopyFolder (lcDevDir, lcBackupDir)
> fso = null
> ?'Finished Successfully'
> ENDIF
> ?'Unsuccessful'
>
>
>
>
> The test IF DIRECTORY(lcBackupDir) fails but when I remove the test the copy proceeds as expected.
>
> Is there a limit on the way directory() works? Or else why does it fail here?
>
> Many thanks for any ideas.
>
>
> -Bryan
Sir
IF DIRECTORY(lcBackupDir)
Will always return false. Try this
IF !DIRECTORY(lcBackupDir)
md (lcBackupDir)
endif
With Regards,
Biju Thomas