×

Discussion Board

Results 1 to 4 of 4

Thread: Dir contents

  1. #1
    Regular Contributor
    Join Date
    Dec 2003
    Posts
    470

    Smile Dir contents

    Hello friends,

    How can I get the names of files in a directory. Can I use RFs for this. Please post sample code if any.

    Best regards,
    Jaak

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,

    look on example - searching for clips:

    RFile file;
    TFileName sound_path;

    // search both: C drive and MMC
    for( TInt i = 0; i < 2 ; i ++ )
    {
    // compose path
    if ( i == 1 )
    sound_path.Copy( PathInfo::PhoneMemoryRootPath() );
    else
    sound_path.Copy( PathInfo::MemoryCardRootPath() );
    sound_path.Append( PathInfo:igitalSoundsPath() );

    // cycle through all found files
    CDir *dir;
    CEikonEnv::Static()->FsSession().GetDir( sound_path, KEntryAttNormal, ESortByDate | EDescending, dir );
    if ( dir )
    {
    CleanupStack::PushL( dir );
    for ( TInt j = 0; j < dir->Count(); j++ )
    {
    TEntry entry = ( *dir )[ j ];
    if ( entry.IsArchive() )
    {
    .......
    }
    }
    CleanupStack::PopAndDestroy(dir);
    }
    }
    }


    Bye
    STeN

    P.S. Curly brackets maybe not paierd well....

  3. #3
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    hi jaak,

    for searching for files you need class RFs.

    some code, which searches for bmp-files:
    _LIT(KWildName1, "*.bmp");
    _LIT(KPathList, "c:\\system\\;c:\\Nokia\\Images\\");
    TBufC<256> pathList(KPathList);
    CDir* fileList;
    TBufC<256> buf;
    RFs session;
    session.Connect();
    CleanupClosePushL(session);
    TFindFile fileFinder(session);
    fileFinder.FindWildByPath(KWildName1, pathList, fileList);
    buf = (*fileList)[index].iName; //for more information read the sdk
    delete fileList;
    CleanupStack::PopAndDestroy();

    for displaying the names of the files I'd use the class CAknDoubleNumberStyleListBox; in that way you can display not only the name but also further informations of the file.

    and next time: a look into the sdk doesn't hurt...
    (it is explained there very well)

    christian

  4. #4
    Regular Contributor
    Join Date
    Dec 2003
    Posts
    470

    Dir

    Friends,

    Thanks for the reply. I will try the given codes.

    Best regards,
    Jaak

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •