Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7840153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:40:37+00:00 2026-06-02T15:40:37+00:00

greetings from Iceland! To begin with, I have searched both with google and here

  • 0

greetings from Iceland!

To begin with, I have searched both with google and here with no result.

I’m writing in Delphi and have couple of years experience in Delphi (over 30 years in Pascal)

I have build over these years variety of files utility’s programs and used the functions FindFirst and FindNext in almost every such app. Today I was using a old file-utility program I wrote and found out it didn’t work 100%

It was ok until the directory name got somehow strange, i.e. name with couple of periods inside. The story is I was installing Wamp and some folders there was named with this strange method.

As: "c:\wamp\apps\phpmyadmin3.4.5"
    "c:\wamp\apps\sqlbuddy1.3.3"
    "c:\wamp\apps\webgrind1.0 etc"

When I did debugging, I found out Findnext just returned error 18 which is same error as FindNext return when no more files is to find.

I have tried FindFirstFile and FindNextFile with same result. I’m thinking to try API FindNextFileEx, if this has to do with long file names, but not so optimistic..

Also I notice the attribute in these folders wasn’t 16 (hex10) instead it was 8208 (8192+16), but it doesn’t have anything to do with this problem as I could for example mask (AND) the attr with $00FF etc.

PROCEDURE TForm_Leit.Finna_Dir (Str_InnDir : STRING);
  VAR
    S_Rec1           : TSearchRec;
    Bo_Buid          : BOOLEAN;
BEGIN
  .
  .
  .
  //Find Dir part
  IF (FindFirst (Str_Inndir+'\*.', faDirectory, S_Rec1) = 0) THEN
  REPEAT
    Bo_Buid := FALSE;
    IF ((S_Rec1.Name = '.') OR (S_Rec1.Name = '..')) THEN
    REPEAT
      Bo_Buid := FindNext (S_Rec1) <> 0;
    UNTIL NOT((S_Rec1.Name = '.') OR (S_Rec1.Name = '..')) OR (Bo_BUid);

    IF NOT(Bo_Buid) THEN
      Finna_Dir (Str_Inndir+'\'+S_Rec1.Name); //Recursion

  UNTIL (FindNext (S_Rec1) <> 0);
END;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:40:42+00:00Added an answer on June 2, 2026 at 3:40 pm

    The pattern you’re using ('\*.') only matches with file and directory names without a period in it (which also means no extension for files). Try with:

    IF (FindFirst (Str_Inndir+'\*', ...
    

    To eloborate a little, VCL’s ‘Find..’ functions are wrappers around the underlying API’s ‘Find..’ functions which does not really care if you want to search for files or folders (the ‘Attr’ parameter you can pass to sysutils.FindFirst is a facility provided by VCL, and the VCL can only effect the search outcome by filtering it). So the result of using a ‘*.‘ pattern will not be different for a file or a folder. If the pattern cannot return a file name with a period in it, then it also cannot return a folder with a period in it.

    The usage of the parameter is the same with the dir command. Navigate to your ‘..\apps’ folder from a command prompt, and if you issue a >dir *. you won’t see the folders in your question listed.

    You can have a look at and try with different ‘Pattern’s in the following sample code ,which only uses the API to enumerate files, to see how different wild cards effect the search outcome.

    var
      Data: TWIN32FindData;
    
    procedure ListFiles(const Path, Pattern: string; List: TStrings);
    
      function IsDot: Boolean;
      begin
        Result := (string(Data.cFileName) = '.') or (Data.cFileName = '..');
      end;
    
      function IsDirectory: Boolean;
      begin
        Result := Bool(Data.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY);
      end;
    
      procedure PutFileName;
      begin
        if not IsDot then begin
          if IsDirectory then
            List.Add(Path + '\' + Data.cFileName + ' <dir>')
          else
            List.Add(Path + '\' + Data.cFileName);                                  //'
        end;
      end;
    
    var
      FindHandle: THandle;
    begin
      FindHandle := FindFirstFile(PChar(Path + Pattern), Data);
      if FindHandle <> INVALID_HANDLE_VALUE then
        try
          PutFileName;
    
          while FindNextFile(FindHandle, Data) do begin
            PutFileName;
            if (not IsDot) and IsDirectory then
              ListFiles(Path + '\' + Data.cFileName, Pattern, List);                //'
          end;
    
        finally
          windows.FindClose(FindHandle);
        end;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    const
      Pattern = '\*';
    begin
      Memo1.Clear;
      ListFiles('..sometestdirectory..', Pattern, Memo1.Lines);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings! I'm trying to have a UIWebView controlled from generated events. Is there a
Greetings. I have a need to have a 'child' modal opended from a colorbox
greetings all i have a problem that when sending an email from the server
Greetings, I've taken over from a prior team and writing ETL jobs which process
Greetings, I have these 2 models: from django.db import models class Office(models.Model): name =
Greetings, I want to write a script that handles simple http requests from Google
Greetings, I have a bash script that parses ZIP files we receive from a
Greetings, I have a servlet which pulls an action parameter from a querystring. Based
Greetings! I have an ASP.NET app that scrapes data from a handful of external
Greetings Stackoverflow How do I set the php $_GET[] array from Jquery? I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.