恳求大家帮忙! 结构化存储,读取文件夹有时会少! ( 积分: 50 )

  • 主题发起人 主题发起人 todaysoft
  • 开始时间 开始时间
T

todaysoft

Unregistered / Unconfirmed
GUEST, unregistred user!
读取系统文件目录时,当是文件类型时有些文件目录里的文件夹总少显示,有些又不会. 非文件夹的不会出现这样的问题. 代码如下:
void __fastcall TImageFileList::ChangeDir(AnsiString dir)
{
TSearchRec SearchRec;
int Attr=0;
int Found ;
AnsiString ExtFileName;
AnsiString temstr;
DWORD ResultAttr;
AnsiString FoundFileName;
Clear();
OtherFileList->Clear();
temstr= dir+"//*.*";
Attr = faAnyFile;

if (FindFirst(temstr, Attr, SearchRec)== 0)
{
do
{
ExtFileName = LowerCase(ExtractFileExt(SearchRec.Name));
if( (ExtFileName==".bmp") || (ExtFileName==".jpg") || (ExtFileName==".jpeg"))
Add(dir+"//"+SearchRec.Name);
else
if ( SearchRec.Attr==faDirectory ) //文件夹 有时会少显示.
{
if (SearchRec.Name.Length()>1)
if (! ((SearchRec.Name[SearchRec.Name.Length()]=='.') &&
(SearchRec.Name[SearchRec.Name.Length()-1]!='.')))
OtherFileList->Add("0#"+dir+"//"+SearchRec.Name) ;
}
else
if (ExtFileName==".txt")
OtherFileList->Add("1#"+dir+"//"+SearchRec.Name);
else
if ((ExtFileName==".htm") || (ExtFileName==".html"))
OtherFileList->Add("2#"+dir+"//"+SearchRec.Name) ;
else
if (ExtFileName==".pas")
OtherFileList->Add("3#"+dir+"//"+SearchRec.Name);
else
if (ExtFileName==".exe")
OtherFileList->Add("4#"+dir+"//"+SearchRec.Name);
else
if (ExtFileName==".dll")
OtherFileList->Add("5#"+dir+"//"+SearchRec.Name) ;
else
if (ExtFileName==".ssp")
OtherFileList->Add("6#"+dir+"//"+SearchRec.Name);
} while ( FindNext(SearchRec)== 0);
FindClose(SearchRec);
}
 
读取系统文件目录时,当是文件类型时有些文件目录里的文件夹总少显示,有些又不会. 非文件夹的不会出现这样的问题. 代码如下:
void __fastcall TImageFileList::ChangeDir(AnsiString dir)
{
TSearchRec SearchRec;
int Attr=0;
int Found ;
AnsiString ExtFileName;
AnsiString temstr;
DWORD ResultAttr;
AnsiString FoundFileName;
Clear();
OtherFileList->Clear();
temstr= dir+"//*.*";
Attr = faAnyFile;

if (FindFirst(temstr, Attr, SearchRec)== 0)
{
do
{
ExtFileName = LowerCase(ExtractFileExt(SearchRec.Name));
if( (ExtFileName==".bmp") || (ExtFileName==".jpg") || (ExtFileName==".jpeg"))
Add(dir+"//"+SearchRec.Name);
else
if ( SearchRec.Attr==faDirectory ) //文件夹 有时会少显示.
{
if (SearchRec.Name.Length()>1)
if (! ((SearchRec.Name[SearchRec.Name.Length()]=='.') &&
(SearchRec.Name[SearchRec.Name.Length()-1]!='.')))
OtherFileList->Add("0#"+dir+"//"+SearchRec.Name) ;
}
else
if (ExtFileName==".txt")
OtherFileList->Add("1#"+dir+"//"+SearchRec.Name);
else
if ((ExtFileName==".htm") || (ExtFileName==".html"))
OtherFileList->Add("2#"+dir+"//"+SearchRec.Name) ;
else
if (ExtFileName==".pas")
OtherFileList->Add("3#"+dir+"//"+SearchRec.Name);
else
if (ExtFileName==".exe")
OtherFileList->Add("4#"+dir+"//"+SearchRec.Name);
else
if (ExtFileName==".dll")
OtherFileList->Add("5#"+dir+"//"+SearchRec.Name) ;
else
if (ExtFileName==".ssp")
OtherFileList->Add("6#"+dir+"//"+SearchRec.Name);
} while ( FindNext(SearchRec)== 0);
FindClose(SearchRec);
}
 
后退
顶部