Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Dec 09, 2018 10:48 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: RESOLVED Overwrite Folder if Already Present
PostPosted: Sun Feb 24, 2013 7:04 am 
Offline

Joined: Fri Jun 05, 2009 4:54 pm
Posts: 484
Location: London, England
Hi,
I have the following code (in a method) which is responsible for backing-up my app's parent folder to my desktop:

Dim i as Integer

if source.directory then // it's a folder
if destination.exists then
if not destination.directory then return // bail out
else
destination.CreateAsFolder
end if
for i = 1 to source.count
CopyFileOrFolder(source.item(i), destination.child(source.item(i).name))
next
else
source.CopyFileTo(destination)
FileCount = FileCount + 1
ProgressBar1.Value = (FileCount / FileTotal) * ProgressBar1.Maximum
ProgressBar1.Refresh
end if


I also have the following code in the window's Activate event:

dim SourceFolder as FolderItem
dim DestFolder as FolderItem
dim d as new date

SourceFolder = app.ExecutableFile.Parent
DestFolder = SpecialFolder.DeskTop.Child(SourceFolder.Name + " Backup " + "(" + str(d.day) + "." + str(d.month) + "." + str(d.year) +")")

FileCount = 0
FileTotal = CountFiles(SourceFolder)
CopyFileOrFolder(SourceFolder, DestFolder)

self.Close

For some reason I can only backup the folder to the desktop ONCE - If I try to do it twice, nothing happens (as if the folder is not being created)

Could someone please help me to cause the folder to be overwritten if it already exists.
Even better if you could help me put all of the combined code into a button's action event.

Thank you all so much.

_________________
RealStudio Professional Edition 2012 r2
Developing on OS X 10.8 (Mountain Lion)
Deploying on Windows XP / Vista / 7 / 8


Last edited by RicSum on Sun Feb 24, 2013 11:59 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Overwrite Folder if Already Present
PostPosted: Sun Feb 24, 2013 10:20 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
dim SourceFolder as FolderItem
dim DestFolder as FolderItem
dim d as new date

SourceFolder = app.ExecutableFile.Parent
DestFolder = SpecialFolder.DeskTop.Child(SourceFolder.Name + " Backup " + "(" + str(d.day) + "." + str(d.month) + "." + str(d.year) +")")

IF DESTFOLDER.EXISTS THEN DESTFOLDER.DELETE

FileCount = 0
FileTotal = CountFiles(SourceFolder)
CopyFileOrFolder(SourceFolder, DestFolder)

self.Close

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group