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(f.name,4) <> ".SCF" Then
f.name= f.name + ".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
Dim f As folderitem
Dim fd As New SaveAsDialog
fd.Filter="PDF"
f = fd.ShowModal
If f <> Nil Then
If Right(f.name,4) <> ".PDF" Then
f.name= f.name + ".PDF"
End If
If f <> Nil Then
//save the file
End If
End If
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.
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"
So far the only thing I have managed to get to work reliably is this:
If Right(f.name,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. )
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.