Testing my little application, I met a problem with Save dialog in Delphi. Normally Save Dialog appears ( I save image file otherwise), but yesterday I tested my app on a computer where all Data were in another partition - in (D:) directory – while system was in (C:) separetely. It does not work: saveDialog.InitialDir := GetCurrentDir; (Save dialog does not appear.) I am a newbie in Delphi and I don’t know how resolve the problem in case of some computers having the programs and the data in two different directories. Please help me, thanks in advance!
Asked
Active
Viewed 820 times
0
-
Could you also show code and tell us which version of Delphi you have. I for one cannot reproduce behaviour like this. For what it is worth, the current directory is usually a poor initial directory. Programs are typically installed in read-only locations. If you simply refrain from setting the initial directory of the dialog you will get the My Documents folder as the default. – David Heffernan Feb 07 '12 at 12:08
1 Answers
0
TSaveDialog
handles multiple partitions just fine. Your problem is related to something else.
With that said, you really should not be relying on GetCurrentDir()
at all, as it dynamically changes during the course of your app's lifetime, so you can never be sure where it actually points to at any given moment. In any case, that alone would not cause TSaveDialog
to fail.
TSaveDialog
uses GetSaveFileName()
internally, so when it does fail, try calling CommDlgExtendedError()
to find out why.

Remy Lebeau
- 555,201
- 31
- 458
- 770