Hey all!! Could some one help me with this one??
The code below will search a folder including subdirectories, and it works the CD’s I’ve tested.
The code works perfectly on a CD (first intentionally to search, but my brother wanted me to enable hard drive search as well), but when I search my hard drive it seams to leave out some files and folders. (Note that I am running Windows Millennium Swedish version) I found out that the program tends to believe some folders are files(?). Followed are some folders listed with their attributes (could the attribs cause this problem? And if so, how do I solve it without changing them?).
‘C:\_restore’ [Hidden] (this one alone holds 5617 files in 5 folders ‘Win inf.’)
’C:\windows\pif\’ [Hidden]
’C:\windows\inf’ [Hidden]
’C:\windows\fonts’ [None]
’C:\windows\web’ [None]
’C:\windows\Cookies’[None]
’C:\windows\Sysbackup’ [Hidden]
’C:\windows\Applog’ [Hidden]
I have a total of 31318 files and 1573 folders (windows information) on my hard drive, but my program only reports 19131 files in 1342 folders!
// Needed for this code is a TButton(or other), TListBox, TRichEdit
void __fastcall Tform1::Button1Click(TObject *Sender)
AnsiString curr_path; // current search path
ListBox1->Items->Add("C:" // start path to search from
while(ListBox1->Items->Count>0) // do while a path exists in ListBox1
{
curr_path = ListBox1->Items->Strings[0]+"\\"; // Change curr_path to first path-string in ListBox1
done = findfirst((AnsiString(curr_path)+"*.*".c_str(), &ffblk,faDirectory);
while (!done)
{
int direct = strcmp(ffblk.ff_name, "."
int subdirect = strcmp(ffblk.ff_name, ".."
if(direct != 0 && subdirect != 0 && ffblk.ff_attrib==FA_DIREC) // make sure the 'name' is a folder
ListBox1->Items->Insert(1, curr_path + ffblk.ff_name ); // add path to ListBox
else if(direct != 0 && subdirect != 0 && ffblk.ff_attrib!=FA_DIREC) // make sure the 'name' isn't a folder
RichEdit1->Lines->Add( curr_path+ffblk.ff_name); // add filename to RichEdit1, incl. fullpath
done = findnext(&ffblk); // find next file
}
ListBox1->Items->Delete(0); // delete currently serached path from ListBox1
}
}
Martin G Broman
mgb_svea@thevortex.com
DWS - Alpha Whitin Dead Wolf Society
The code below will search a folder including subdirectories, and it works the CD’s I’ve tested.
The code works perfectly on a CD (first intentionally to search, but my brother wanted me to enable hard drive search as well), but when I search my hard drive it seams to leave out some files and folders. (Note that I am running Windows Millennium Swedish version) I found out that the program tends to believe some folders are files(?). Followed are some folders listed with their attributes (could the attribs cause this problem? And if so, how do I solve it without changing them?).
‘C:\_restore’ [Hidden] (this one alone holds 5617 files in 5 folders ‘Win inf.’)
’C:\windows\pif\’ [Hidden]
’C:\windows\inf’ [Hidden]
’C:\windows\fonts’ [None]
’C:\windows\web’ [None]
’C:\windows\Cookies’[None]
’C:\windows\Sysbackup’ [Hidden]
’C:\windows\Applog’ [Hidden]
I have a total of 31318 files and 1573 folders (windows information) on my hard drive, but my program only reports 19131 files in 1342 folders!
// Needed for this code is a TButton(or other), TListBox, TRichEdit
void __fastcall Tform1::Button1Click(TObject *Sender)
AnsiString curr_path; // current search path
ListBox1->Items->Add("C:" // start path to search from
while(ListBox1->Items->Count>0) // do while a path exists in ListBox1
{
curr_path = ListBox1->Items->Strings[0]+"\\"; // Change curr_path to first path-string in ListBox1
done = findfirst((AnsiString(curr_path)+"*.*".c_str(), &ffblk,faDirectory);
while (!done)
{
int direct = strcmp(ffblk.ff_name, "."
int subdirect = strcmp(ffblk.ff_name, ".."
if(direct != 0 && subdirect != 0 && ffblk.ff_attrib==FA_DIREC) // make sure the 'name' is a folder
ListBox1->Items->Insert(1, curr_path + ffblk.ff_name ); // add path to ListBox
else if(direct != 0 && subdirect != 0 && ffblk.ff_attrib!=FA_DIREC) // make sure the 'name' isn't a folder
RichEdit1->Lines->Add( curr_path+ffblk.ff_name); // add filename to RichEdit1, incl. fullpath
done = findnext(&ffblk); // find next file
}
ListBox1->Items->Delete(0); // delete currently serached path from ListBox1
}
}
Martin G Broman
mgb_svea@thevortex.com
DWS - Alpha Whitin Dead Wolf Society