Save a database file with extension

Hi everybody !

How can I add in my file the extension .sqlite ?

file.Name = file.Name+".sqlite" as no reaction !
I want write ‘DataBase’ or ‘DataBase.sqlite’ on dialog => to have a file withe the name : ‘DataBase.sqlite’
If I don’t type .sqlite, XOJO must add alone this extension.
How can I do or how can XOJO make this ?

This is code of my button :

[code]Dim dialog As SaveAsDialog
Dim file As FolderItem

//create the dialog (does not actually show it)
dialog = New saveAsDialog

// The filter is what type of file you are saving (for cosmetic purposes)
// The filters are defined in the File Types dialog
// inside the edit menu
dialog.Filter = “text/sql”
dialog.PromptText = “Donner un nom la base de donne”
dialog.Title = “Enregistrer la base de donne”
dialog.suggestedFileName=“DataBase_Test”
dialog.CancelButtonCaption = “Annuler”
dialog.ActionButtonCaption = “Enregistrer”

Dim SQLiteType As New FileType
SQLiteType.Name = “text/sql”
SQLiteType.MacType = "SQL "
SQLiteType.MacCreator = “”
SQLiteType.Extensions = “sqlite”

// Also, you can display the dialogs as sheets
// by calling dialog.ShowModalWithin(Self)
//
// For regular modal dialogs, just call dlg.showModal
file = dialog.ShowModal

//then test for nil to see if the user clicked cancel
If file <> Nil Then
file.Name = file.Name+".sqlite"
'file.DisplayName = file.DisplayName +".sqlite" // ??? error
'file.Name = file.Name +".sqlite" // ??? error

Dim dbFile As New FolderItem

dbFile = file

If dbFile <> Nil And dbFile.Exists Then
  dbFile.Delete
End If

mDb = New SQLiteDatabase
mDb.DatabaseFile = dbFile

If mDb.CreateDatabaseFile Then
  mIsConnected = True
  T_Info.Text = "Cration de la database : " + file.AbsolutePath
Else
  mIsConnected = False
  T_Info.Text = "Error creating SQLite database: " + mDb.ErrorMessage
End If

Else
T_Info.Text = “Enregistrement annul”
End If[/code]

Change the name after you create it.

Why need :
Dim SQLiteType As New FileType
…

How can I use FileType ?
I think that we can use FileType to add automatically on my file when I save it.

Try adding the filetypeset to your project instead of instantiating it in code. That may help. Windows does automatically append the extension, but I have no idea what OS X does.

Try adding the filetypeset to your project instead of instantiating it in code.

What’s mean ?
I can’t understand, can you detail (more) explain ?
I’m new with XOJO :slight_smile:
I begin to try play with XOJO. I’m a old 4D’s programmer.

Select the menu option Insert -> File Type Set

Click the icon with the “+” sign to add a new File Type to the File Type Set. Fill out the fields as needed.

The User Guide, Book 3: Framework has a section on File Type Sets.

I want to see you my copy screen, how can I do in this Forum ?

Cool,
Thank Tim
It’s works like this :

… 'dialog.Filter = "text/sql" dialog.Filter = FileType_SQLite.SQLite dialog.PromptText = "Donner un nom à la base de donnée" …

File Type Set :
DisplayName : SQLite
Objet Name : SQLite
MacType :
MacCreator :
Extensions : sqlite
UTI’s :
Icone :

Big THANK, XOJO add alone the extension.
You are the BEST, Tim :wink:

Good to hear it.