Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

C++Builder Developer on StackOverflow was having trouble with SysUtils FindFirst / FindNext not finding all files with extension ~1~ and other strange file extensions.

Here was my answer 😀

Create a New | C++Builder VCL Windows application. On the form add TPanel, TButton, TEdit and TMemo components. Put the TButton and TEdit into the TPanel. Set TPanel align property to AlTop. Set the TMemo align property to alClient.

FindFirst’s declaration in SysUtils.hpp is:

[crayon-675011cbcd153371948438/]

The key point is to included any or all of the file attributes (integer parameter Attr) for files that you want to find. The file attribute choices are defined in “C:\Program Files (x86)\Embarcadero\Studio\21.0\include\windows\rtl\windows\rtl\System.SysUtils.hpp”:

[crayon-675011cbcd15d134231042/]

The following code will display all items in a directory including the ., .., .~* files – for example in a C++Builder project’s history folder.

[crayon-675011cbcd160275900668/]

I put the string: C:\Users\david\Documents\Embarcadero\Studio\Projects\CBuilder\FindFirstVCLCpp\__history\*.* in the EditBox. After clicking the Button, the TMemo contained the following contents.

Screen Grab of running C++Builder FindFirst app

References

System.SysUtils.FindFirst

System.SysUtils.FindNext

To find more C++Builder StackOverflow questions and answers use the C++Builder SO Tag 😀

Exit mobile version