【发布时间】:2020-05-05 19:35:27
【问题描述】:
我需要能够在运行 Windows DNS 服务器的 Windows server 2016 实例上枚举C:\Windows\system32\dns 下存在的文件夹。
尝试了FindFirst()/FindNext() 并没有得到任何结果,我构建了一个快速的 VCL 表单应用程序来了解发生了什么。我有一个TButton 和一个TEdit,按钮的OnClick 如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
FDir := 'C:\Windows\System32\';
with TFileOpenDialog.Create(nil) do
try
Title := 'Select Directory';
Options := [fdoPickFolders, fdoPathMustExist, fdoForceFileSystem];
OkButtonLabel := 'Select';
DefaultFolder := FDir;
FileName := FDir;
if Execute then
Edit1.Text := Filename;
finally
Free;
end;
end;
当我以管理员身份或通常在服务器上运行此程序并尝试浏览到 FileOpenDialog 中的文件夹 C:\Windows\system32\dns\ 时,我收到一个错误:
Windows 找不到“C:\Windows\system32\dns”。检查拼写并重试。
但是,我知道该文件夹存在,我可以使用服务器上的 Windows 资源管理器浏览它,因此肯定是 Delphi 代码存在问题,或者应用程序运行的权限存在问题。
请问,谁能建议我需要做些什么来解决这个问题?
【问题讨论】:
-
删除
fdoForceFileSystem是否有同样的问题? -
构建 64 位程序。或者阅读文件系统重定向器。
-
@RemyLebeau 是的,删除 fdoForceFileSystem 后它的行为仍然相同。
标签: delphi