searching a file and its path in all drive
| Mon, 2005-07-18 11:11 | |
|
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. |
|






Forum posts: 76
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
Forum posts: 165
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
Forum posts: 46
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:
{
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;
}