Force Extension when saving- workaround doesnt!

Over the years, a number of posts have mentioned that setting a filter or a file type and trying to save, gets you a file with no extension.
I’ve replied to some of them myself, to say my workaround is to check and append the extension if need be,

But now I’m finding even that doesnt work…

Xojo 2018 R3

  If Right(,4) <> ".SCF" Then + ".SCF"
  End If

The first line spots that the extension is missing
The second line is called
After which the file name still lacks an extension.

How can I force it, how can it STILL be missing after line 2?

Edit, if I get the folderitem as the return result for a GetSaveFolderItem call, the test and the addition of extension DOES work.
Its like the folderitem object returned by SaveAsDialog is a read-only object

1 Like

checked the FolderItem.DisplayName ?
Maybe the extention is hidden?

I did, and it isnt.

1 Like

@Jeff_Tullin can you create a simple sample project please?

I had the same issue last week on Linux and it was fixed by Xojo the same day. In my case this was Linux only, macOS and Windows worked fine.

They aren’t going to fix it in 2018. :slight_smile:

Here is the entire test project:

Dim f As folderitem
Dim fd As New SaveAsDialog

f = fd.ShowModal

If f <> Nil Then
  If Right(,4) <> ".PDF" Then + ".PDF"
  End If
  If f <> Nil Then
    //save the file
  End If
End If

Try setting the filter to


I think the “problem” is, you/users have to add “.pdf” within the SaveAsDialog, otherwise you get an FolderItem without extension. I suggest to use a File Type Group and set it via fd.Filter = FileTypeGroup1. Then your “problem” should gone.

This makes no difference.


Your solution and mine are effectively identical so I don’t know how you come to this conclusion.

Filter is a String and assigning a FileTypeGroup to it gets you the extensions defined therein.

I will clarify though. You must include the period in front of the extension for it to work.

I simply tried it with your suggestion :slight_smile:

Setting a FileTypeGroup works fine in this sample.

Not for me.
The screenshot doesnt show it working here anyway.
The arrow points to displayname, and that WILL omit extension if the user has chosen to hide them.

.Name isnt visible in your screenshot.
And period or not, filetype or not, adding .PDF to the name property doesn’t add the extension to the saved file if the user hasnt typed one.

Myfile remains Myfile even after the line that should have made it Myfile +".PDF"

Right Jeff. The screenshot shows, Gregs suggestion doesn’t work (for me).

Look at my suggestion, which works for me:

So far the only thing I have managed to get to work reliably is this:

  If Right(,4) <> ".PDF" Then 
    f = GetFolderItem(f.NativePath + ".PDF",3)
  End If

Basically, forcing a new folderitem to be created.

Thanks all for looking.
(No point me shouting about 2018 - I know Xojo consider that dead.
But 2020 doesn’t produce deliverable products for me on just about any project I have created since I bought it. :frowning: )

Imagine that your FileType (FT_PDF) have “application/pdf” as name.

Can you try:

fd.Filter = "application/pdf" // Instead of FT_PDF.All

I have a solution, but:
“application/pdf” doesnt look like a filter to me

@Jeff_Tullin have you tried this?

If you mean
fd.Filter = FileTypeGroup1
Yes I tried it, but all I get is an error.
FileTypes are not working for me in this project: despite being set up, using one does not work… I get an NOE.

I even copied a set from a different working project.
That’s a mystery but since I was already frustrated by the original issue, I didn’t feel inclined to spend any time on debugging the workaround.

Which error? Can you share a screenshot?