Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 13:19, 8 December 2007.

Find Files

From Forum Nokia Wiki

Following code snippet illustrate finding files from the given path.

void CYrContainer::FindFile()
    {
    _LIT(KPath,"C:\\System\\"); // Give your path here
    _LIT(KFileName,"*.txt"); // Give file name here
    RFs aFs;
    aFs.Connect();
    CleanupClosePushL(aFs);
    CDesCArrayFlat* aFiles = new (ELeave) CDesCArrayFlat(5);
    CleanupStack::PushL(aFiles);
	
    StartScanL(aFs, KPath, KFileName, aFiles);
	
    CleanupStack::PopAndDestroy(aFiles);
    CleanupStack::PopAndDestroy(&aFs);
    }
 
void CYrContainer::StartScanL(
    RFs aFs, const TDesC& aPath, const TDesC& aWild, CDesCArray* aArray)
    {
    CDirScan* DirScan = CDirScan::NewLC(aFs);
    DirScan->SetScanDataL(aPath, 
        KEntryAttDir|KEntryAttMatchExclusive, 
        ESortNone, CDirScan::EScanDownTree);
 
    while(1)
        {
        CDir* dir = NULL;
        TRAPD(error, DirScan->NextL(dir));
        if (error || !dir)
            break;
		
        delete dir;
 
        ScanDirectoryL(aFs, DirScan->FullPath(), aWild, aArray);
        };
    CleanupStack::PopAndDestroy(DirScan);
    }
 
void CYrContainer::ScanDirectoryL(
    RFs& aFs, const TDesC& aDir, const TDesC& aWild, CDesCArray* aArray)
    {
    TParse parse;
    parse.Set(aWild, &aDir, NULL);
    TPtrC spec(parse.FullName());
 
    TFindFile FindFile(aFs);
    CDir* dir;
 
    if (!FindFile.FindWildByPath(parse.FullName(), NULL, dir))
        {
        CleanupStack::PushL(dir);
 
        for(TInt i = 0; i < dir->Count(); i++)
            {
            parse.Set((*dir)[i].iName, &spec, NULL);
            aArray->AppendL(parse.FullName());
            }
        CleanupStack::PopAndDestroy(dir);
        }
    }

Output: All files under C:\System\ having extension .txt will be stored in an array aFiles.

  • Replace KPath and KFileName as per your requirements.

Related Discussions
Thread Thread Starter Forum Replies Last Post
How to modify the UID3 after creating a project? yfw1966 Symbian Signing, Certification and Security 13 2008-06-25 08:56
Funny prob advocatee General Symbian C++ 0 2003-06-22 20:18
Apll download files via GPRS? ctpthanh Symbian Networking & Messaging 0 2005-05-17 03:04
description problem doesitmatter General Symbian C++ 3 2007-11-27 22:28
How to put MIDlets into the 3410 wiasoft Mobile Java General 1 2002-05-29 09:49
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX