[fpc-pascal] Function for checking correct file name

Krzysztof dibo20 at wp.pl
Fri Sep 14 14:48:08 CEST 2012


I just quicky googled not allowed characters and wrote this simple function:

function IsValidFilename(const AFilename: String): Boolean;
var
  c: set of Char = ['<','>',':','"','/','\','|','?','*', '%', '.'];
  i: Integer;
begin
  Result := True;
  for i:=1 to Length(AFilename) do
    if AFilename[i] in c then
      Exit(False);
end;

So, problem solved. Thanks and regards



More information about the fpc-pascal mailing list