CreateInputDirPage/TInputDirWizardPage 不创建所选目录

CreateInputDirPage/TInputDirWizardPage does not create the selected directory

我需要在我的数据库文件设置结束时浏览或创建一个新目录。

我创建一个 TInputDirWizardPage 来选择目录,然后我使用一个按钮启动数据库安装。

我的问题是没有创建新目录并且数据库安装失败。

这是我的代码:

[Code]
var         
    Page0: TInputQueryWizardPage;
    Page1: TInputDirWizardPage;        

{ Launch DB CLIP installation }
procedure ButtonOnClick(Sender: TObject);
var
    Params: string;
    ScriptPath: string;
    ResultCode: Integer;
    DBPath: string;
    Server: String;
    Instance: String;
    SQL_User: String; 
    SQL_Password: String;

begin
    DBPath := Page1.Values[0];
    Server:= Page0.Values[0];
    Instance:= Page0.Values[1];
    SQL_User:= Page0.Values[2]; 
    SQL_Password:= Page0.Values[3];
    ScriptPath := ExpandConstant('"{app}\DB\Create Database 2.12.3.sql"');
    Params := '-v CLIPDATA="'+DBPath+'" CLIPINDEX="'+DBPath+'" CLIPLOG="'+DBPath+'" -S '+Server+'\'+Instance+' -U '+SQL_User+' -P '+SQL_Password+' -i '+ScriptPath ;

    if  MsgBox('' + Params + '', mbInformation, mb_YesNo) = idYes then
        Exec ('sqlcmd',Params, '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
    Exit;
end;

procedure InitializeWizard();
var
    DBButton: TNewButton;        
begin
    Page0 := CreateInputQueryPage(wpInfoAfter,
        'SQL Informations', '',
        'Please specify Server and Instance name , then click Next.');

    Page0.Add('Server:', False);
    Page0.Add('Instance:', False);
    Page0.Add('SQL User:', False);
    Page0.Add('SQL Password:', True);
    Page0.Values[0] := ('localhost');
    Page0.Values[1] := ('CLIP');
    Page0.Values[2] := ('sa');
    Page0.Values[3] := ('clip');

    Page1 := CreateInputDirPage(Page0.ID,
        'Select CLIP Database files Location', '',
        'CLIP DB data files will be stored in the following folder.'#13#10#13#10 +
        'To continue, click Next. ' +
        'If you would like to select a different folder, click Browse.',
        False, 'New Folder');

    Page1.Add('Database Folder');
    Page1.Values[0] := ExpandConstant('{pf}\CLIP\CLIP_DATA\DB\');

    DBButton := TNewButton.Create(Page1);
    DBButton.Left := ScaleX(16);
    DBButton.Top := ScaleY(205);
    DBButton.Width := ScaleX(100);
    DBButton.Height := ScaleY(25);
    DBButton.Caption := 'Install DB CLIP';
    DBButton.OnClick := @ButtonOnClick;
    DBButton.Parent := Page1.Surface;
end;

CreateInputDirPage 不会自行创建所选目录。

新建文件夹 按钮不会创建物理文件夹。它只在树中创建一个虚拟节点。

我知道这与 documentation 有点矛盾,它说:

Make New Folder button will be shown that creates a new folder with the specified default name.


如果您真的想为所选路径创建一个物理文件夹,请在您的 ButtonOnClick 处理程序中使用 CreateDir function

if not DirExists(DBPath) then
begin
  CreateDir(DBPath);
end;