TTS000208
开发伙伴平台:
设备, 软件版本: 无
大类: Symbian C++
子类: 普通
说明:
程序一般安装在手机内或存储卡内,下列代码允许程序动态生成其安装路径,当程序访问同目录下文件时可以使用。
这是通过CompleteWithAppPath(TDes& aFileName)完成的,所有的结果(包括盘符、路径和文件名,以及扩展名)都可在给定的描述符中返回。
include <aknutils.h> // for CompleteWithAppPath()
// aFileName parameter contains the name of the file to open,
// without any path information
void CSomeAppClass::OpenFileL(const TFileName& aFileName)
{
TFileName fullPath(aFileName);
// insert the full application path into the file name
CompleteWithAppPath(fullPath); // from aknutils.h
... // (proceed to open the file)
}
如,该应用程序安装在手机内存中,则下列代码:
_LIT(KDataFileName, “data.dat”);
OpenFileL(KDataFileName);
从C盘打开的文件可为:c:/system/apps/myapp/data.dat