searching a file and its path in all drive

Login to reply to this topic.
Mon, 2005-07-18 11:11
Joined: 2005-06-11
Forum posts: 85
Hi,

I have to search a file on mobile and to get fullpath of this  file.
I came to know that this can be done by TFindFile but it needs some specific directory.......while I dont want to do this....
I have to give only filename in coding.....please help me....how I can do that......please send me some sample code....

Thanks in advance...

Pankaj

Wise People talk because they have something to say . Fools talk because thay have to say somthing.


Tue, 2005-07-19 13:39
Joined: 2005-06-01
Forum posts: 76
Re: searching a file and its path in all drive
Pankaj,

RFs::DriveList() will give you total number of Drives on a device.
RFs::GetDir() will give you the total no of file and directories ... you can iterate throug all the folders to find a specific file.

..
KiraN Puranik
Thu, 2005-09-01 08:59
Joined: 2005-08-19
Forum posts: 165
Re: searching a file and its path in all drive
Hi! How can I use RFs::DriveList()  and RFs::GetDir() ? Does it return the names of Dir?

One more thing, how can I print the filenames using DrawText? I understand that I have to declare constant strings to use DrawText....?

Please........... Thankssss

bob_marley Afro
Fri, 2005-09-02 13:32
Joined: 2005-05-09
Forum posts: 46
Re: searching a file and its path in all drive
Hi Bob,

Here is little sample of what can be done. This code does the following:
1] Displays all the available drives
2] Displays all the files under C:\

The code is just a little bit of slapdash thrown together, but it should give you the general idea:

Code:
void CFileSysControl::Draw(const TRect& /*aRect*/) const
{
RFs fs;
fs.Connect();

// GC: obtain list of available drives
TDriveList driveList8;
TInt RVal = fs.DriveList(driveList8);

// GC: obtain list of entries in the root of C drive
CDir *dirs;
        fs.GetDir(_L("C:\\"), KEntryAttNormal, ESortByUid, dirs);
fs.Close();

// GC: Get graphics context for rendering screen
CWindowGc& gc=SystemGc();  // Get graphics context
TRect rect=Rect();        // Get control extent
gc.DrawRect(rect);        // Draw border and fill

// GC: Set the font
const CFont* font=iEikonEnv->SymbolFont();
gc.UseFont(font);
gc.SetPenColor(KRgbRed);

// GC: Write the drive list out to disk
char ch = 'A';
TBuf16<1> chBuf;
TInt x = 10, y = 15;

gc.DrawText(_L("Available Drives:"), TPoint(5,10));

// GC: Display available drives
for (TInt i = 0; i < KMaxDrives; ++i)
{
if (driveList8[i])
{
chBuf.Append(ch);
y+=15;
gc.DrawText(chBuf, TPoint(x,y));
chBuf.Zero();
}
++ch;
}
y+=15;

// GC: Display contents of the C drive
gc.SetPenColor(KRgbGreen);
gc.DrawText(_L("Entires in the root of C:"), TPoint(5,y));
y+=15;
for (i = 0; i < dirs->Count(); ++i)
{
TEntry entry = (*dirs)[i];
gc.DrawText(entry.iName, TPoint (10, y));
y+=15;
}
gc.DiscardFont();
delete dirs;
}
  • Login to reply to this topic.