更改 Delphi OpenDialog 的目录 + Win7下驱动
似乎在 Win7 上,当新目录位于与当前目录不同的驱动器上时,更改 TOpenDialog.InitialDir
不起作用。
例如:我想将我的 InitialDir
从 'C:\program files\MyApp' 更改为 'D:\test\MyAppData'
这是一个已知问题,还是仅在我的电脑?
我已经尝试过同样的事情,如以下帖子中所述,但没有成功: 更改 Delphi OpenDialog 的目录
编辑: 我在 Win7 32 位上使用 DelphiXE
路径/目录是正确的:因此,当我从代码复制该路径并将其粘贴到该对话框本身的“文件名”字段中并按 ENTER 时,该对话框将切换到该目录。只是,在我的代码中它不起作用。
更新:
我发现了问题。如果路径包含一些路径命令,例如 ..\
,则 TOpenDialog.InitialDir
无法解决该问题。使用 TPath.GetFullPath(...)
使其干净。
It seems that on Win7 changing the TOpenDialog.InitialDir
doesn't work, when the new directory is on a different drive, than the current directory.
e.g.: I want to change my InitialDir
from 'C:\program files\MyApp' to 'D:\test\MyAppData'
Is that a known issue, or only on my computer?
I already tried the same thing, as mentioned in the following post, but without any success:
Changing the directory of Delphi OpenDialog
EDIT:
I am using DelphiXE on Win7 32 Bit
The path/dir is correct: So, when I copy that path from code and past it into the 'File Name' field of that Dialog itself and I press ENTER, then the Dialog switches to that directory. Only, in my code it is not working.
UPDATE:
I found the problem. If the path contains some path commands like ..\
the TOpenDialog.InitialDir
is not able to resolve that. Use TPath.GetFullPath(...)
to make it clean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经在 Delphi XE 上进行了测试,它运行良好...我已经这样做了:
放置一个新表单:
及其源代码:
问候
I have tested on a Delphi XE, it runs fine... I have done this:
Put a new form:
And its source code:
Regards
我在更改
InitialDir
时没有任何问题,无论是通过对象检查器还是运行时(Win7 和 Delphi 2010)。尝试仔细检查您尝试更改的目录是否输入正确。I don't have any problem changing
InitialDir
, either through object inspector or runtime (Win7 with Delphi 2010). Try doublechecking if the directory you try to change to is correctly typed.