GetSaveFolderItem - Invoking with a new file name not in a directory

I am using OpenDialog as a replacement for GetSaveFolderItem. I am using the former because I need the ability to use InitialFolder to set where I want to store a file. The problem I have is that as a “Save As” function, I need dlg.ShowModal to not give me a “file not found” pop-up when I press the “Action” button in the Save window when the file doesn’t exist. I set SuggestedFileName to the filename I want to either create or write over.
GetSaveFolderItem. worked fine for creating the file if it needed to, but it had no option in setting the default directory.
Any ideas?

OpenDialog is for Opening an existing file. Surely you want SaveFileDialog, it is the modern version of GetSaveFolderItem:

  • Opening a file, reads it from disk into memory is some way.
  • Saving a file, allows you to create a new file on disk (or overwrite an existing one) from something in memory.

James, what platform does your app run on?

Windows 11

I don’t see there is a difference:
https://documentation.xojo.com/api/user_interface/desktop/savefiledialog.html
The code on this Xojo page is basically the code I’m using. It will overwrite a file if it exists, but it will give me a “file not found” dialog instead of simply creating it.

The difference is exactly what you are asking about. It’s a matter of intent.

If you use OpenDialog then the system insists that a file exists on disk, reporting an error if the file provided does not exist. After all how can you Open a file that does not exist.

If you use SaveAsDialog and you click or enter on an existing file name it will warn you that the file already exists and asks if you would like to overwrite it.

Understood. Perhaps my search skill are suffering. Did you see the link I sent? The title is “SaveFileDialog” but the example uses OpenDialog. But now I know what to look for… I see this and other notes…

Thanks for the help. I’m sure SaveFileDialog will work for me.This was in that category of, there’s got to be a way to do this." And there it was.

Then the example is either wrong or the text talks about both operations. Yup the example is wrong. You should add a bug report about the documentation.