Can I do like this?
.h
RPointerArray<HBufC> filesList;//save all of the images's path include file name
.cpp
CDataManager::~CDataManager()
{
iFilesList.ResetAndDestroy();
iFilesList.Close();
}
void CDataManager::CreateFileList()
{
RFs fs;
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);
_LIT(PhoneImagePath, "C:\\Data\\Images\\");
_LIT(KImageName,"*.jpg");
CDirScan* scan = CDirScan::NewLC(fs);
scan->SetScanDataL(PhoneImagePath, KEntryAttNormal|KEntryAttHidden,
ESortByDate, CDirScan::EScanDownTree);
FOREVER//for(;
{
CDir* DirList = 0;
TRAPD(error, scan->NextL(DirList));
if (error || !DirList)
{
break;
}
delete DirList;
FindFile(fs, scan->FullPath(), KImageName);
};
CleanupStack::PopAndDestroy(2); //scan, fs
}
void CDataManager::FindFile(RFs& aFs, const TDesC& aDir, const TDesC& aImageWild)
{
CDir* dirList;
TFindFile FindObj(aFs);
TInt j = FindObj.FindWildByDir(aImageWild, aDir, dirList);
if( j == KErrNone )
{
for(TInt i=0; i < dirList->Count(); i++)
{
TFileName fullname(aDir);
fullname.Append((*dirList)[i].iName);
HBufC *buf = HBufC::NewL(fullname.Length());
*buf = fullname;
filesList.Append(buf);
}
}
}
Please tell me where the mistakes are?
Thank you!




