×
Namespaces

Variants
Actions

如何得到程序路径

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 29 Jun 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

程序一般安装在手机内或存储卡内,下列代码允许程序动态生成其安装路径,当程序访问同目录下文件时可以使用。

这是通过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

This page was last modified on 15 December 2011, at 13:13.
27 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×