Open SaveAs Dialog to the last Directory I saved to


My code below Saves a Canvas Image to my created Windows Application Documents Directory. I want to improve the user experience. If I save to a new windows directory location I want it to remember that new directory location in the SaveAs Dialog. The next new SavedAs Image Item keeps defaulting back to my Application Directory then I have to click to the new directory all over again.

I’ve found a few code samples in the Xojo Old & New Docs from FolderItem.FromSaveInfo. I’m trying to incorporate in my code below with no success. I noticed there’s has been some syntax changes for the more current Xojo Releases. I’m using an older xojo version as of now. How do I incorporate this to my code below to keep it simple as possible?

Dim pic as new Picture(Canvas.Width, Canvas.Height,32)
  Canvas.drawinto(, 0, 0)
  Dim dlg as SaveAsDialog
  Dim f, g as FolderItem
  dlg = new SaveAsDialog
  dlg.Title = "Save PNG Picture File"
  dlg.SuggestedFileName = "Scale Diagram.png"
  dlg.Filter = FileTypes1.PngType  + FileTypes1.JpgType + FileTypes1.bmpType
  //Open SaveAs Dialog To Appilcation Directory
    Dim ImgDir As FolderItem  = SpecialFolder.Documents.Child("Application").Child("Application Data")
    dlg.InitialDirectory =  ImgDir

  f = dlg.ShowModal
  If f <> Nil Then
    pic.Save(f, pic.SaveAsPNG)
  End If

If you don’t set InitialDirectory, it happens automatically.


Hi Tim

I commented out that line of code and sure enough it opened up in my my last different SaveAs Directory from a couple of days ago. Question - If it’s the very first SaveAs does it open in my Document Application Directory once you change that it will remember your very last one you saved in? If that’s so it’s definitely the simplest fix. Thank You