首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian英文资料 >> base >> 正文
List the files from a Directory
作者:佚名    文章来源:不详    更新时间:2006-5-7 10:59:30

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:


RFs fileSession;
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);
相关文章:
How to reset the alternate makmake entry in Codewarrior
Carbide.vs - Disabling the MMP/PKG File update feature
Codewarrior: how to avoid the "Too Many Include Paths" error when using the UIQ 2.1 SDK
Carbide.c++: Setting up On Target Debugging
Getting the Current Cell Id using Symbian S60
Display the extended panic code in Emulator or Device
Start automatically an application or an exe after its installation
Compress Your Symbian C++ Executables
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号