Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Biju Thomas
  Where is Biju Thomas?
 Kochi
 India
 Biju Thomas
 To: bryan wetton
  Where is bryan wetton?
 Morphett Vale
 Australia
 bryan wetton
 Tags
Subject: RE: directory() command
Thread ID: 209882 Message ID: 209886 # Views: 43 # Ratings: 1
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Thursday, January 01, 2009 3:39:16 AM         
   


> 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



COMPLETE THREAD
directory() command Posted by bryan wetton @ 1/1/2009 1:38:18 AM
RE: directory() command Posted by Biju Thomas @ 1/1/2009 3:39:16 AM
RE: directory() command Posted by Vladimir Zografski @ 1/1/2009 2:45:37 PM
RE: directory() command Posted by mike castillo @ 1/1/2009 3:03:35 PM
RE: directory() command Posted by Vladimir Zografski @ 1/1/2009 4:30:42 PM
RE: directory() command Posted by Biju Thomas @ 1/1/2009 4:24:09 PM
RE: directory() command Posted by Jyothish KV @ 1/1/2009 1:23:25 PM
RE: directory() command Posted by Andy Kramek @ 1/1/2009 1:27:50 PM
RE: directory() command Posted by Biju Thomas @ 1/1/2009 4:29:13 PM