Henry Olive 5 Posted October 22, 2022 Good Day, Delphi 10.3 To Connect my Database (FB3) i use an INI file (it is in my EXE Path) which is like below [DataPath] Dir=MySrv:c:\MyApp\Data\ ( I fill the database name in Delphi ) In my program there is a Menu which shows (open) the BackUp Folder to the user, with below code BackUpPath := MyIniFile.ReadString('DataPath', 'Dir', '') + 'BackUp'; // MySrv:c:\MyApp\Data\BackUp ShellExecute(Handle, 'Open', PChar(BackUpPath), Nil, Nil, SW_SHOWNORMAL); Since BackUpPath = MySrv:c:\MyApp\Data\BackUp , above ShellExecute command doesnt work ShellExecute requires just c:\MyApp\Data\BackUp portion of the BackUpPath (Server's Local Path) I can do it with below codes , and i get correct result with below RightWord variable and ShellExecute works correctly but I think there should be a better way S:= MySrv:c:\MyApp\Data\BackUp if Pos('c:\',S) > 0 then X:=Pos('c:\',S) else X:=Pos('C:\',S); LeftWord:=Copy(S,1,X-1); RightWord:=Copy(S,X,Length(S)); which is c:\MyApp\Data\BackUp Thank You Share this post Link to post
Vandrovnik 214 Posted October 22, 2022 (edited) I would suggest to store "server" and "database folder" as separate fileds in your INI. Server=MySrv: Dir=C:\MyApp\Data\ It is much easier than to properly split it later. (App installed on another drive than C : , database on linux server, embedded database with empty server name etc.) Edited October 22, 2022 by Vandrovnik Share this post Link to post
Fr0sT.Brutal 900 Posted October 24, 2022 (edited) Just break the string by ":" and then use proper filename functions upon the right part (ExtractFilePath etc) Edited October 24, 2022 by Fr0sT.Brutal Share this post Link to post
Vandrovnik 214 Posted October 24, 2022 11 minutes ago, Fr0sT.Brutal said: Just break the string by ":" and then use proper filename functions upon the right part (ExtractFilePath etc) This will not work with connection string for embedded Firebird. Share this post Link to post