Article View: borland.public.cppbuilder.nativeapi
Article #11431Some advice on finding files and subdirs
From: Greg Stantin
Date: Tue, 10 Feb 2004 23:18
Date: Tue, 10 Feb 2004 23:18
45 lines
2535 bytes
2535 bytes
I am using the currect code to search for and display files in a
tree. Even though it works okay, it still displays some dirs with
a plus sign in the tree, as thought there are files in that dir. But
when i click on the plus sign, there is nothing there. I double
check in explorer, and there is nothing there. Is there anything
i can do to make it report correctly?
void TForm1::BuildTreeView(TTreeNode* ANode, const AnsiString APath)
{
WIN32_FIND_DATA Data, Dummy;
TTreeNode* Node;
//find a file or a directory
HANDLE FileHandle = FindFirstFile((APath + "*.*").c_str(), &Data);
if(FileHandle != INVALID_HANDLE_VALUE)
{
do
{
if(AnsiSameText(Data.cFileName, ".") ||
AnsiSameText(Data.cFileName, ".."))
continue;
if(ANode != NULL)
Node = TreeView1->Items->AddChild(ANode,
Data.cFileName);
else
Node = TreeView1->Items->Add(NULL, Data.cFileName);
//if the directory has been found, build the dir.
if(Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
Node->HasChildren = FindFirstFile((APath +
Data.cFileName + "\\*.*").c_str(), &Dummy) != 0;
}
while(FindNextFile(FileHandle, &Data));
FindClose(FileHandle);
}
}
//--------------------------------------------------------------------
-------
My next step will be to display only folders in the tree, and when i
click on the folder node
it will display the files from that dir in a listview.
Technical Details
Message-ID:
<402966b0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,fcdbc28037201e15,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-10 15:40:00 PST Reply-To: "Greg Stantin" <gstantin@stantonassoc.com> From: "Greg Stantin" <gstantin@stantonassoc.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Some advice on finding files and subdirs Date: Tue, 10 Feb 2004 17:18:17 -0600 Lines: 47 Organization: Stantin Assoc. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 65.71.57.35 Message-ID: <402966b0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1076455088 65.71.57.35 (10 Feb 2004 15:18:08 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail