Главная страница | назад





Article #28475: How to ensure that a path name ends with a trailing path delimiter ('\').

QUESTION:

How can I make sure that a backslash is added to the end of a path

ANSWER:

Delphi has a function called: IncludeTrailingPathDelimiter. This will return a string with a backslash '/' added to the end, if it does not already have one. Below is one example of how this function works. There is another function called: IncludeTrailingBackslash, this is only included for backwards compatibility (this function should not be used).


procedure TForm1.Button1Click(Sender: TObject);
var
DirPath : string;
begin
DirPath := Edit1.Text;
ShowMessage(IncludeTrailingPathDelimiter(DirPath));
end;

Last Modified: 28-FEB-02