Filename Renaming Problem (Make Backup of existing Database)

I try to make a backup of an existing database. I use the example /Database/SQLite/SQLiteBackup.xojo_binary_project and it works.
My problem is, I do not want to ask the user for the destination folder and filename, I want to use the existing folder, rename the filename to mydatabase.sql_
What happens: my existing database file is renamed after this line

 backupFile.Name = backupFile.Name + "_" + backupDate

and no backup file is created. Don’t understand why, because I do a copy/clone with the ‘New’ at line 1.

Full code:

[code] Dim backupFile As Folderitem = New FolderItem(pDatabase.DatabaseFile)

Dim now As Date = New Date
Dim backupDate As String = str(now.Year) + “.” + Format(now.Month,“00”) +"." + Format(now.Day,“00”) + “_” + Format(now.Hour,“00”) + Format(now.Minute,“00”) + Format(now.Second,“00”) 'creates a string like 2014.05.27_1920

backupFile.Name = backupFile.Name + “_” + backupDate

'backupFile = GetSaveFolderItem("", “backup.sqlite”) <- works

If backupFile Is Nil Then Return false

mBackupDB = New SQLiteDatabase
mBackupDB.DatabaseFile = backupFile
If mBackupDB.CreateDatabaseFile Then
mBackupHandler = New BackupHandler
'mBackupHandler.BackupProgressBar = BackupProgress
pDatabase.BackUp(mBackupDB, mBackupHandler)
End If[/code]

If you change the Name property of a folderitem, even a copy of one, it renames the file. What you want is to use Child to get a new folderitem with a new name.

backupFile = pDatabase.DatabaseFile.Parent.Child(pDataBase.DatabaseFile.Name + "_" + backupDate)

DatabaseFile.Parent gets the folder the database is in.
DatabaseFile.Parent.Child() gets a brand new folderitem in the same directory with the new name.

Don’t fully understand it but it works. Thanks Tim!

what part do you not understand so we can help you understand it.