Alex Rivera | Logout

Should I use String instead of TFilename?

Asked 2012-05-02T14:51:29.680
16

When passing filename parameters to procedures/functions, should I use TFilename or String.

If there is a difference, what is it, and what are then potential ramifications if using a String?

e.g.

procedure TForm1.OpenFile(const AFilename : String);
begin
    //Open the file if it exists
    ...
end;
Edit
Report

1 Answer

19

I think TFilename should be used when developing components because that way IDE can show it's property editor (TOpenDialog will be shown when clicked on ellipsis in the property inspector).

Other than this there is basically no difference which one to use. Remember that if you use TFilename you must add SysUtils to your uses clause.

answered 2012-05-02T14:57:58.880

Your Answer