Example: File: CopyMe.txt Location: Userhome directory/MyFiles Copy to: Userhome directory/MyCopyFiles
DIM sSourcePath, sCopyPath AS String sSourcePath = User.Home & "/MyFiles" sCopyPath = User.Home & "/MyCopyFiles" 'First check if file exists If Exist(sSourcePath & "/CopyMe.txt") THEN 'Now check if copyto directory exists IF NOT (Exist(sCopyPath)) THEN MKDIR sCopyPath ENDIF 'Now check if file exists IF NOT (Exist(sCopyPath & "/CopyMe.txt")) THEN COPY sSourcePath & "CopyMe.txt" TO sCopyPath & "/CopyMe.txt" ELSE 'If Exists first remove old file then copy new file KILL sCopyPath & "/CopyMe.txt" COPY sSourcePath & "CopyMe.txt" TO sCopyPath & "/CopyMe.txt" ENDIF ENDIF This will only generate errors in case you have not enough access rights on the directory. Hope this helps... Willy On wo, 2012-02-08 at 13:14 -0800, abbat wrote: > Sorry, if it's abasic question (but GAMBAS is Almost mean BASIC :-)) > > How to copy a file if it is already exist? > And do not get any error. > Overwrite > > Tnx. -- Met vriendelijke groeten/ With kind regards, Willy Raets, Voorzitter/chairman, Earthship Belgium vzw. Nederlandse website: http://www.earthshipbelgium.be/nl.html English Website: http://www.earthshipbelgium.be/en.html ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user