I'm trying to use the TDirectory.GetFiles function, but when I add a TSearchOptions third parameter to force a recursive search the compiler raises an error saying that soAllDirectories has not been declared.
uses System.IOutils,
System.Types;
procedure TfrmConversio.btnConversioClick(Sender: TObject);
var FilesPas: TStringDynArray;
begin
FilesPas := TDirectory.GetFiles('C:\Project', '*.pas', soAllDirectories);
ProgressBar1.Max := Length(FilesPas);
end;
What am I doing wrong ?. I can see that constant in System.IOUtils.
Thank you.
You need to write
TDirectory.GetFiles('C:\Project', '*.pas', TSearchOption.soAllDirectories);
The reason is that the compiler directive {$SCOPEDENUMS ON}
is found before the definition of the TSearchOption
type. This means precisely that you need to qualify the enumeration's constants with the type name.
From the documentation:
The $SCOPEDENUMS directive enables or disables the use of scoped enumerations in Delphi code. More specifically, $SCOPEDENUMS affects only definitions of new enumerations, and only controls the addition of the enumeration's value symbols to the global scope.
In the {$SCOPEDENUMS ON} state, enumerations are scoped, and enum values are not added to the global scope. To specify a member of a scoped enum, you must include the type of the enum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With