I’m trying to save a Image that will open the SaveAsDilog to a specific Windows Documents Folder. So far my code below opens the Save As Dialog to my Documents Directory. If my Documents Directory is “C:\Users\MyName\Documents\MyProgram\My Images” . How would I rewrite
“dlg.InitialDirectory = SpecialFolder.Documents”
[code]Dim pic as new Picture(cvsCapturPic.Width, cvsCapturPic.Height,32)
cvsCapturPic.drawinto(pic.graphics, 0, 0)
Dim dlg as SaveAsDialog
Dim f as FolderItem
dlg = new SaveAsDialog
My personal recommendation is never set the InitialDirectory property. The OS will use the last directory the user navigated to, and users expect this. Setting the InitialDirectory value destroys this user expectation, and in most cases makes your app harder to use.
UX warning aside, SpecialFolder.Documents gets you to the Documents folder, so since you want two folders deeper, just use children of that.
The quick’n’dirty way (without error checking, and could cause a NilObjectException) would be:
dim fMyDocumentsChild as FolderItem = SpecialFolder.Documents.Child("MyProgram").Child("My Images")
dlg.InitialDirectory = fMyDocumentsChild
tried that for a while.
But when your app can look for pictures over THERE, Excel documents over THERE, save File Type A HERE, and possibly file type B THERE, leaving the OS to handle it can be more annoying.
I maintain several ‘last used locations’ for various purposes.