简体   繁体   English

在Delphi中保存对话框,数据位于不同的分区中

[英]Save Dialog in Delphi, Data are in a different partition

Testing my little application, I met a problem with Save dialog in Delphi. 测试我的小应用程序后,我在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. 通常会出现“保存对话框”(否则将保存图像文件),但是昨天我在所有数据都位于(D :)目录中的另一个分区中而系统分别位于(C :)中的计算机上测试了我的应用程序。 It does not work: saveDialog.InitialDir := GetCurrentDir; 它不起作用: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. (不会出现“保存”对话框。)我是Delphi的新手,如果某些计算机在两个不同的目录中都有程序和数据,我也不知道如何解决该问题。 Please help me, thanks in advance! 请帮助我,在此先感谢!

TSaveDialog handles multiple partitions just fine. TSaveDialog处理多个分区就可以了。 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. 话虽如此,您实际上根本不应该依赖GetCurrentDir() ,因为它会在应用程序的生命周期中动态变化,因此您永远无法确定它在任何给定时刻实际指向何处。 In any case, that alone would not cause TSaveDialog to fail. 无论如何,仅此一项就不会导致TSaveDialog失败。

TSaveDialog uses GetSaveFileName() internally, so when it does fail, try calling CommDlgExtendedError() to find out why. TSaveDialog内部使用GetSaveFileName() ,因此当它确实失败时,请尝试调用CommDlgExtendedError()以找出原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM