New topic: 

Overwrite Folder if Already Present

<http://forums.realsoftware.com/viewtopic.php?t=47053>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        RicSum          Post subject: Overwrite Folder if Already 
PresentPosted: Sun Feb 24, 2013 7:04 am                         
Joined: Fri Jun 05, 2009 4:54 pm
Posts: 397
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.

Thank you all so much.      
_________________
RealStudio Professional Edition 2011 Release 4 & 2012 Release 1.2
Developing on OS X  10.8 (Mountain Lion)
Deploying on Windows XP / 7 / 8  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to