🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #5002

directory list problems

#5002
From: robert
Date: Tue, 25 Oct 2005 17:33
36 lines
2049 bytes
Hello all.
I am writing a program to list a whole directory, and of course I have one problem. When I call the routing the first time it is perfect, but the others time I try to call the same routine It doesn't work: "GetLastError" is == ERROR_NO_MORE_FILES ! Why that ? I have to reset something ?

.....
    ShowDir();   // ok it work
    ShowDir();   // GetLastError == ERROR_NO_MORE_FILES
    ShowDir();   // GetLastError == ERROR_NO_MORE_FILES
    ShowDir();   // GetLastError == ERROR_NO_MORE_FILES
.....


void __fastcall TForm1::ShowDir()
{
        String tmp,tmp2;
        SHFILEINFO FileInfo2 = {NULL};
        WIN32_FIND_DATA FileData = {NULL};
        HANDLE hFind = NULL;

        hFind = FindFirstFile("c:\\*.*", &FileData);
        if (hFind == INVALID_HANDLE_VALUE)
        {
                Memo->Lines->Add("Invalid file handle : error "+IntToStr(GetLastError));
                return;
        }

        String temp;
        while(GetLastError() != ERROR_NO_MORE_FILES)
        {
                ........ my code here
                FindNextFile(hFind, &FileData);
        }
        FindClose(hFind); // Free the dir structure
}

Thank you very much
Technical Details
Message-ID: <435e6c76$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fb06c70f9d4d1eee,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "robert" <rob@no-spam.boo>
Sender: "robert" <rob@no-spam.boo>
Reply-To: "robert" <rob@no-spam.boo>
Subject: directory list problems
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 82.54.217.170     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <435e6c76$1@newsgroups.borland.com>
Date: 25 Oct 2005 10:33:42 -0700
X-Trace: newsgroups.borland.com 1130261622 207.105.83.66 (25 Oct 2005 10:33:42 -0700)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail