得到文件路径信息 TParse
2010-01-18 23:44
162 查看
得到文件路径信息 TParse
上面根据 DriveList 及 Drive 方法可以得到驱动信息信息
DriveList 需要 CDir 对像保存列表,CDir 中的每一个数据都是 TEntry 类型的,所以根据 TEntry 可以得到驱动器及文件的信息
Drive()方法根据传入的参数得到 TDriveInfo 信息,根据 TDriveInfo 可以得到 iDriveAtt,iMediaAtt,iType,iBattery 属性,
在 sdk 中查询得到详细说明,进而得到驱动器信息
Volume() 方法可以得到 TVolumeInfo ,这个能得到驱动器的大小及可用空间,名字等信息(名字在模拟器上得不到,不知为什么)
得到一个目录是否存在可以通过下面的代码实现
现在需要解析一个带有全路径的文件该怎么办?
可以使用 TParse 对像,使用 Parse对像时,先要通过 Set 方法去赋于一个全路径的字符串,然后通过 FullName(),Drive(),Path(),Ext(),Name()
分别得到 全名,所在驱动器名,路径,扩展名及名字
请看以下示例
示例代码来自于 sdk 例子,代码可是我一点点敲上去的
安平2009@原创
qi_jianzhou@126.com
上面根据 DriveList 及 Drive 方法可以得到驱动信息信息
DriveList 需要 CDir 对像保存列表,CDir 中的每一个数据都是 TEntry 类型的,所以根据 TEntry 可以得到驱动器及文件的信息
Drive()方法根据传入的参数得到 TDriveInfo 信息,根据 TDriveInfo 可以得到 iDriveAtt,iMediaAtt,iType,iBattery 属性,
在 sdk 中查询得到详细说明,进而得到驱动器信息
Volume() 方法可以得到 TVolumeInfo ,这个能得到驱动器的大小及可用空间,名字等信息(名字在模拟器上得不到,不知为什么)
得到一个目录是否存在可以通过下面的代码实现
TInt err=fsSession.MkDir(KMessage3); if (err!=KErrAlreadyExists) // Don't leave if it already exists User::LeaveIfError(err); |
可以使用 TParse 对像,使用 Parse对像时,先要通过 Set 方法去赋于一个全路径的字符串,然后通过 FullName(),Drive(),Path(),Ext(),Name()
分别得到 全名,所在驱动器名,路径,扩展名及名字
请看以下示例
void parseNames(const TDesC& aFileName); void fileNames() { _LIT(KFuncName,"\nDoParsing()\n"); console->Printf(KFuncName); _LIT(KParse1,"d:\\path\\fn.ext"); parseNames(KParse1); _LIT(KParse2,"autoexec.bat"); parseNames(KParse2); _LIT(KParse3,"c:readme"); parseNames(KParse3); _LIT(KParse4,"c:\\include\\stdio.h"); parseNames(KParse4); _LIT(KParse5,".prof.ile"); parseNames(KParse5); _LIT(KParse6,"autoexec.*"); parseNames(KParse6); } void parseNames(const TDesC& aFileName) { User::LeaveIfError(ifs.Connect()); _LIT(KFullName,"Full name=%S\n"); _LIT(KPathComponents,"Dirve=%S path=%S name=%S ext=%S\n"); _LIT(KFullNameText,"full name against session path=%S\n"); _LIT(KExtension,".txt"); _LIT(KParsePath,"FullName against session path and default extension .txt=%S\n"); TParse p; User::LeaveIfError(p.Set(aFileName,NULL,NULL)); console->Printf(KFullName,&p.FullName()); TFileName driveName(p.Drive()); TFileName pathname(p.Path()); TFileName filename(p.Name()); TFileName extension(p.Ext()); console->Printf(KPathComponents,&driveName,&pathname, &filename,&extension); User::LeaveIfError(ifs.Parse(aFileName,KExtension,p)); console->Printf(KParsePath,&(p.FullName())); ifs.Close(); } |
安平2009@原创
qi_jianzhou@126.com
相关文章推荐
- SQL语句(sp_helpdb)查看数据库属性信息,查看数据库文件路径用得到
- python获得路径和子路径下所有的文件的相关信息
- C# WinForm拖入文件到窗体,得到文件路径
- bat读取文件夹下某一类文件的路径信息表
- C#之WinForm基础 得到保存文件对话框保存的文件路径
- c++builder选择文件,并得到文件路径!OpenDialog Edit!
- Python实现给文件添加内容及得到文件信息的方法
- android--------根据文件路径使用File类获取文件相关信息
- linux 内核中得到 当前进程 对应的可执行文件的 绝对路径
- PHP pathinfo()获得文件的路径、名称等信息说明
- caffe训练得到文件路径名并做好标记
- 配置文件中有“路径信息”时,需呀注意的问题(路径中的\是转义字符)~
- vbs读取文件内的信息将非有效数据移动到指定路径
- 已知某个文件的全部路径,如d:\aa\bbb\ccc\0.jpg 如何得到0.jpg的父目录名称cc呢?
- 得到文件系统的 管理信息
- [AHK]用快捷键得到当前选中文件的路径
- java程序打包成jar 配置文件信息路径
- vbs读取文件内的信息将对应数据拷贝到其他路径
- JSP 自己写的在JSP页面得到文件的服务器路径,并对XML文件进行读写(以对Tomcat的conf目录中的context.xml文件为例)
- QT QString根据路径获取文件名称以及所在文件夹等信息