RFs fs;
fs.Connect();
//取出所有盘符
TDriveList dList;
fs.DriveList(dList);
TChar driveLetter;
//从磁盘A开始,遍历到磁盘Z
for(TInt driveNum=EDriveA; driveNum<=EDriveZ; driveNum++)
{
if(dList[driveNum]) //如果列表中该项的值不为空,则表明设备上有该磁盘
{
fs.DriveToChar(driveNum, driveLetter); //将数值转成字符
console->Printf(_L("disk drive : %c \n"), driveLetter);
TBuf<8> dLetter;
dLetter.Append(driveLetter);
dLetter.Append(_L(":\\"));//生成路径
CDir *dirList;
fs.GetDir(dLetter, KEntryAttNormal | KEntryAttMatchMask, ESortByDate, dirList); //取该路径下的所有文件信息
TInt count = dirList->Count();
for(TInt i=0; i < count; i++)
{
//下面这句要注意,是指值之后再用索引取信息
TEntry& entry = (TEntry&)(*dirList)[i];
//Printf也可以像普通的printf函数一样打印信息
console->Printf(_L("FileName : %s \n"), entry.iName.Ptr());
}
delete dirList;
dirList = NULL;
}
}