View Full Version : How to get all filenames within one directory???


09-12-2002, 09:01 AM
I'm using this...

CDir* fileList;
User::LeaveIfError(fsSession.GetDir(KDir,
KEntryAttNormal,ESortByName,fileList));

_LIT16(KString,"%S");

for (TInt i=0;i<fileList->Count();i++)
{
?????
}

What do I have to put in here (???)?

I'd like to copy all those file names in an array of TDes...
By the way, how do I get the date/time of the file...?

Hope you can help me very fast...

C'ya

cmatthee
09-12-2002, 09:19 AM
[code:1]CDesCArray* filenamearray;

for (TInt i=0; i<fileList->Count(); i++)
{
TEntry& entry = (*fileList)[i];
TPtrC filename = entry.iName;
filenamearray.AppendL(filename);
TTime lastmodified = entry.iModified;
}[/code:1]

MaleBuffy
09-12-2002, 09:42 AM
cmatthee nice avatar :evil:

09-12-2002, 11:16 AM
I tried something different, because I wanted to search for TXT-Files...

WHY DOES THAT NOT WORK???

[code:1]

_LIT(aWildname,"*.txt");
_LIT(aScanDir, "\\system\\apps\\automat\\");
TFindFile file_finder(fsSession);
CDir* file_list;

TInt err = file_finder.FindWildByDir(aWildname,aScanDir, file_list);
while (err==KErrNone)
{
TInt i;
for (i=0; i<file_list->Count(); i++)
{
TParse fullentry;
fullentry.Set((*file_list)[i].iName,& file_finder.File(),NULL);
// Do something with the full filename...
// ...
}
delete file_list;
err=file_finder.FindWild(file_list);
}
[/code:1]

I get err=-1;

But Dir exists!!!

C'Ya

call2kk
10-03-2005, 12:34 PM
_LIT(dir,"c:\\"); //here put ur dir name..
CDir *fileList;
RFs opensession;
RFile file; // for writing all the file name in a file..
opensession.Connect(); //connect to fille server

if(opensession.SetSessionPath(setpath)!=KErrNone) // optional if u want to set path
Exit();
if(file.Replace(opensession,KCipherFileName,EFileW rite)!=KErrNone)
Exit();
TBuf8<256>data;
if(opensession.GetDir(dir,KEntryAttReadOnly,ESortB yName,fileList)==KErrNone)
{
TInt k=fileList->Count();
TFileName c;
for (TInt i=0;i<k;i++)
{
TEntry entry =(*fileList)[i];
TPtrC filename = entry.iName;
c.Append(filename);
}
data.Append(c);
file.Write(data);

krishna from telibrahma