×
Namespaces

Variants
Actions

Read files from a folder

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: symbianyucca (10 Apr 2007)
Last edited: hamishwillee (18 Sep 2012)

The GetFilesFromFolderL() method illustrates how to use GetDir() function in RFs to read all files from a specified folder. (*File_list)[i] gives you the TEntry of the selected file, so you can also use its functions to determine more information of the file before adding it to your array list.

void GetFilesFromFolderL(TDesC& aFolder,CDesCArray* aArray)
{
CDir* File_list(NULL);
 
if(KErrNone == CCoeEnv::Static()->FsSession().GetDir(aFolder,
KEntryAttMaskSupported, EDirsFirst, File_list))
{
if(File_list && aArray)
{
File_list->Sort(ESortByName);
for(TInt i=0; i < File_list->Count(); i++)
{
if((*File_list)[i].IsSystem()
|| (*File_list)[i].IsHidden()
|| (*File_list)[i].IsDir())
{
// ignore System & Hidden Files & folders
}
else
{
aArray->AppendL((*File_list)[i].iName);
}
}
}
 
delete File_list;
File_list = NULL;
}
}
This page was last modified on 18 September 2012, at 08:33.
45 page views in the last 30 days.