This code is to filter the files of desired extension from a folder
Header Reqired:
#include <f32file.h>
Library Needed:
LIBRARY efsrv.lib
In class declaration add these lines
RArray<TEntry> iFileList;
_LIT(KFileExtension,"*.mp3"); _LIT(KDirPath,"c:\\Nokia\\Sounds\\Digital\\"); void CMyclass::ListDirectory( ) { CDir* dirs = 0; CDir* files = 0; User::LeaveIfError(iFsSession.GetDir(KDirPath,KEntryAttNormal,ESortByName,files, dirs)); TFindFile findFiles( iFsSession ); TInt err = findFiles.FindWildByDir( KFileExtension, KDirPath, files ); CleanupStack::PushL( dirs ); CleanupStack::PushL( files ); //get files in base path while (err == KErrNone) { for( TInt i=0; iCount(); i++ ) { iFileList.Append( (*files)[i] ); } err = findFiles.FindWild( files ); } CleanupStack::PopAndDestroy( 2 ); }
Now iFileList contains the files of desired extension. Here the list will contain only the mp3 files from c:\Nokia\Sounds\Digital directory
See also: Directory Monitoring