Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Borislav Borissov
  Where is Borislav Borissov?
 Sofia
 Bulgaria
 Borislav Borissov
 To: Shaheryar Rashed
  Where is Shaheryar Rashed?
 Multan
 Pakistan
 Shaheryar Rashed
 Tags
Subject: RE: file already exist
Thread ID: 393668 Message ID: 393669 # Views: 63 # Ratings: 2
Version: Visual FoxPro 6 Category: Forms
Date: Saturday, December 21, 2013 9:16:00 AM         
   


> Hi Experts!
>
> i have following code for backup,
>
msource1 = 'D:\Accounts'
> mdest1 	 = 'd:\Backup\Upload'
> doBackup(msource1, mdest1)
> procedure doBackup
> 
> LPARAMETERS _SourceFolder,_targetFolder
> IF EMPTY(m._SourceFolder) OR TYPE('m._SourceFolder')#'C'
> 	WAIT WINDOW "Source folder not specified" NOWAIT 
> 	RETURN .f.
> ENDIF 
> IF EMPTY(m._SourceFolder) OR TYPE('m._targetFolder')#'C'
> 	WAIT WINDOW "Target folder not specified" NOWAIT 
> 	RETURN .f.
> ENDIF 
> _SourceFolder=ADDBS(FULLPATH(m._SourceFolder))
> _targetFolder=ADDBS(FULLPATH(m._targetFolder))
> IF _SourceFolder=_targetFolder
> 	WAIT WINDOW "Source and Target is same" NOWAIT 
> 	RETURN .f. 
> ENDIF 
> IF !DIRECTORY(_SourceFolder)
> 	WAIT WINDOW "Source folder does not exist" NOWAIT 
> 	RETURN .f.
> ENDIF 
> IF !DIRECTORY(_targetFolder)
> 	MD (_targetFolder)
> ENDIF 
> IF !DIRECTORY(_targetFolder)
> 	WAIT WINDOW "Target folder can not be created" NOWAIT 
> 	RETURN .f.
> ENDIF 
> LOCAL m.cZipFileName
> m.cZipFileName=_targetFolder + 'Back' + ".zip"
> strtofile("PK"+chr(5)+chr(7-1)+replicate(chr(0),18),m.cZipFileName)
> 
> oShell=CREATEOBJECT("shell.application")
> oShell.NameSpace(m.cZipFileName).copyhere(oShell.nameSpace(_SourceFolder))
> WAIT 
> RENAME ("D:\BACKUP\UPLOAD\back.zip") TO ("D:\BACKUP\UPLOAD\back.zi") 

>
> it shows a message that "File already exist" i have to replace this one if exist... guide me how i do ?

...
 m.cZipFileName=_targetFolder + 'Back' + ".zip"
IF NOT EMPTY(SYS(2000, m.cZipFileName))
   ERASE (m.cZipFileName)
ENDIF
...

or put SET SAFETY OFF at the beginning of the code

-----------------
Borislav Borissov

Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.

ENTIRE THREAD

file already exist Posted by Shaheryar Rashed @ 12/21/2013 9:07:55 AM
RE: file already exist Posted by Borislav Borissov @ 12/21/2013 9:16:00 AM