List the files from a Directory
In order to list the files from a directory, you need to use the RFs class (RFs is a class that allows you to access the file server).
The method TInt RFs::GetDir(const TDesC& aFileSpec, TUint anEntryAttMask, TUint anEntrySortKey, CDir*& anEntryList) returns a CDir pointer, which list all file entries in directory aFileSpec (the return value should be KErrNone).
The following example creates a listing and opens all files:
RFile file;
CDir* dirList;
TInt i;
TBuf<50> totalPath;
TBuf<30> fileName;
_LIT(KDirName, "C:\\FolderXY\\");
_LIT(KFileSpec,"C:\\FolderXY\\*.*");
//
// Connect to the file server
//
fileSession.Connect();
CleanupClosePushL(fileSession);
//
// Get the file list, sorted by name
// (Leave if an error occurs)
//
User::LeaveIfError(
fileSession.GetDir(KFileSpec,
KEntryAttMaskSupported,
ESortByName,
dirList));
CleanupStack::PushL(dirList);
//
// Process each entry
//
for (i=0;i<dirList->Count();i++)
{
fileName = (*dirList)[i].iName;
totalPath = KDirName;
totalPath.Append(fileName);
DoAnythingYouWantWithTheFile(totalPath);
}
//
// Close the connection with the file server
// and destroy dirList
//
CleanupStack::PopAndDestroy(2);






> List the files from a Directory
2 observations i have about working with RFs.
first, you need to delete the CDir object that gets populated otherwise it will result in memory leaks. :(
second, you don't have to specify *.* for the wildcards. * alone is enough to match files with and without extensions.
> List the files from a Directory
> List the files from a Directory
you need to change
_LIT(KDirName,"C:\\FolderXY\\"); _LIT(KFileSpec,"C:\\FolderXY\\*.*");
from
_LIT(KDirName,"C:\FolderXY\"); _LIT(KFileSpec,"C:\FolderXY\*.*");
so that code can work properly as no new line is permitted in constant
> List the files from a Directory
> List the files from a Directory
> List the files from a Directory
Good Day! :)
I would just like to ask if it is possible to list the files found from this code onto a list box other than that of a console. I am trying to create an audio player with playlist support. It would be really helpful. Thank you.
jax
> List the files from a Directory
Is there any problem keeping the dirlist open? I am writing a program where I will repeatedly loop through a list. Every time the program chooses one song to play.
Is there any problem just freeing the dirlist in the destructor of my object or do I need to construct and free the dirlist once for every call?
List the files from inbox or Phonebook Directory
please advice me about listing files from inbox or phonebook directory
thank you very much :-)
need your help urgently PLZZZZZZZZZZZZZzzz
Hi I am really new to Symbian and have compiled small applications, But don't know how to complie 2-3 applications together.
1) Suppose there are two seperate progs then how to combine them and make it to One.
2) The code to see the files in the directory is to be added in which file.
I have a project submission coming up by end of this week. Plz help me.
this article is unuseful