Delphi FMX 手机目录提取,把IO相关的都提取到System.IoUtils单元中
2015-08-06 09:22
519 查看
Delphi把IO相关的都提取到System.IoUtils单元中。
路径操作使用TPath的方法都很方便。
uses
System.IoUtils
TPath.GetTempPath//临时目录
TPath.GetCameraPath//照相机目录(照片/录像)
TPath.GetMusicPath//音乐目录
TPath.GetDownloadsPath//下载目录
……
如果使用TPath类的静态方法那么代码就是跨平台的,在Windows,Mac,iOS,Android上都能用。如果仅仅对Android的操作也可以使用Androidapi.IOUtils单元的那些GetXX的函数,也很简单,都没有参数,并且返回值都是字符串。
可以用任何一个事件测试一下:
showmessage('GetCachePath:' + TPath.GetPathRoot(TPath.GetCachePath));
showmessage('GetTempPath:' + TPath.GetTempPath);
showmessage('GetHomePath:' + TPath.GetHomePath);
showmessage('GetDocumentsPath:' + TPath.GetDocumentsPath);
showmessage('GetSharedDocumentsPath:' + TPath.GetSharedDocumentsPath);
showmessage('GetSharedPicturesPath:' + TPath.GetSharedPicturesPath);
showmessage('GetSharedDownloadsPath:' + TPath.GetSharedDownloadsPath);
showmessage('GetCachePath:' + TPath.GetCachePath);
showmessage('GetCameraPath:' + TPath.GetCameraPath);
showmessage('GetPicturesPath:' + TPath.GetPicturesPath);
showmessage('GetPublicPath:' + TPath.GetPublicPath);
以下是用nubia z5手机测试的结果(都是TPath下的函数,最后都没有/):
GetRandomFileName:L8d4hdw0.W2d
GetTempFileName:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/tmp/tmp.qqvwf21410
GetTempPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/tmp
GetHomePath:/data/data/com.embarcadero.Project1/files
GetDocumentsPath:/data/data/com.embarcadero.Project1/files
GetSharedDocumentsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files
GetLibraryPath:/data/app-lib/com.embarcadero.Project1-2
GetCachePath:/data/data/com.embarcadero.Project1/cache
GetPublicPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files
GetPicturesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Pictures
GetSharedPicturesPath:/storage/sdcard0/Pictures
GetCameraPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/DCIM
GetSharedCameraPath:/storage/sdcard0/DCIM
GetMusicPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Music
GetSharedMusicPath:/storage/sdcard0/Music
GetMoviesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Movies
GetAlarmsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Alarms
GetSharedAlarmsPath:/storage/sdcard0/Alarms
GetDownloadsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Download
GetSharedDownloadsPath:/storage/sdcard0/Download
GetRingtonesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Ringtones
GetSharedRingtonesPath:/storage/sdcard0/Ringtones
路径操作使用TPath的方法都很方便。
uses
System.IoUtils
TPath.GetTempPath//临时目录
TPath.GetCameraPath//照相机目录(照片/录像)
TPath.GetMusicPath//音乐目录
TPath.GetDownloadsPath//下载目录
……
如果使用TPath类的静态方法那么代码就是跨平台的,在Windows,Mac,iOS,Android上都能用。如果仅仅对Android的操作也可以使用Androidapi.IOUtils单元的那些GetXX的函数,也很简单,都没有参数,并且返回值都是字符串。
可以用任何一个事件测试一下:
showmessage('GetCachePath:' + TPath.GetPathRoot(TPath.GetCachePath));
showmessage('GetTempPath:' + TPath.GetTempPath);
showmessage('GetHomePath:' + TPath.GetHomePath);
showmessage('GetDocumentsPath:' + TPath.GetDocumentsPath);
showmessage('GetSharedDocumentsPath:' + TPath.GetSharedDocumentsPath);
showmessage('GetSharedPicturesPath:' + TPath.GetSharedPicturesPath);
showmessage('GetSharedDownloadsPath:' + TPath.GetSharedDownloadsPath);
showmessage('GetCachePath:' + TPath.GetCachePath);
showmessage('GetCameraPath:' + TPath.GetCameraPath);
showmessage('GetPicturesPath:' + TPath.GetPicturesPath);
showmessage('GetPublicPath:' + TPath.GetPublicPath);
以下是用nubia z5手机测试的结果(都是TPath下的函数,最后都没有/):
GetRandomFileName:L8d4hdw0.W2d
GetTempFileName:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/tmp/tmp.qqvwf21410
GetTempPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/tmp
GetHomePath:/data/data/com.embarcadero.Project1/files
GetDocumentsPath:/data/data/com.embarcadero.Project1/files
GetSharedDocumentsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files
GetLibraryPath:/data/app-lib/com.embarcadero.Project1-2
GetCachePath:/data/data/com.embarcadero.Project1/cache
GetPublicPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files
GetPicturesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Pictures
GetSharedPicturesPath:/storage/sdcard0/Pictures
GetCameraPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/DCIM
GetSharedCameraPath:/storage/sdcard0/DCIM
GetMusicPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Music
GetSharedMusicPath:/storage/sdcard0/Music
GetMoviesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Movies
GetAlarmsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Alarms
GetSharedAlarmsPath:/storage/sdcard0/Alarms
GetDownloadsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Download
GetSharedDownloadsPath:/storage/sdcard0/Download
GetRingtonesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Ringtones
GetSharedRingtonesPath:/storage/sdcard0/Ringtones
相关文章推荐
- Delphi TMemo 可以显示、编辑多行文本
- Delphi7第八天---小型图书管理系统
- delphi 日志单元
- Delphi使用wxsqlite加密Sqlite数据库
- delphi 图像处理 图像左旋右旋
- delphi 图像处理 图像放大缩小
- delphi 图像处理 二值化
- Delphi学习手记——单引号和双引号的区别
- *Delphi多线程的OnTerminate属性(附加一个关于临界区线程同步的例子)
- Delphi二维码中文支持、分组、批量打印经验小结
- Delphi函数重载时参数类型问题
- Delphi常用的快捷键
- delphi 控件大全
- Delphi DLL的创建、静态 以及动态调用
- Delphi XE8,C++ Builder XE8,RAD Studio XE8 Update1 精简版
- 46 Useful Utility Functions For #Delphi XE8
- Delphi 接口托管实现
- DELPHI中自定义消息的发送和接收
- DELPHI 泛型
- *Delphi中ExtractFilePath、ParamStr以及更多文件/目录操作涉及的函数。附加对应的例子