Getting application installation path
Article Metadata
End user can install application on either C: (Phone Memory) or E: (Memory Card- MMC). Sometimes programmers need to know which is the installation drive.
CompleteWithAppPath() from aknutils.h is used to determine installation path of the application.
void CYrContainer::GetFullPathL(const TFileName& aFileName)
{
TFileName completePath(aFileName);
// insert the full application path into the file name
CompleteWithAppPath(completePath); // from aknutils.h
//Just for displaying what we have got in 'completePath'
CAknInformationNote* info= new(ELeave) CAknInformationNote;
info->ExecuteLD(completePath);
// implement your own logic once you get complete path
.....
.....
}
Now call GetFullPathL() according to your requirements.
Following are some sample scenario which illustrate usage of CompleteWithAppPath().
Scenario 1:
We need to open/read Test.txt file which is supplied to application installation path.
_LIT(KMyFileName, "Test.txt");
TBuf16<50> FileName;
FileName.Copy(KMyFileName);
GetFullPathL(FileName);
-------------------------------------
Output: C:\System\apps\myapp\Test.txt
or
E:\System\apps\myapp\Test.txt
Scenario 2:
We need to open/read Test.txt file which is supplied to root directory.
If your file is located on root, then feed following path
_LIT(KMyFileName, "\\Test.txt");
TBuf16<50> FileName;
FileName.Copy(KMyFileName);
GetFullPathL(FileName);
-------------------
Output: C:\Test.txt
or
E:\Test.txt
Scenario 3:
We need to open/read Test.txt file which is supplied to \System folder.
If your file is located on \System, then feed following path:
_LIT(KMyFileName, "\\System\\Test.txt");
TBuf16<50> FileName;
FileName.Copy(KMyFileName);
GetFullPathL(FileName);
--------------------------------
Output: C:\System\Test.txt
or
E:\System\Test.txt

