• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

DelphiFMX手机目录提取,把IO相关的都提取到System.IoUtils单元中

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
DELPHI解析JSON发布时间:2022-07-18
下一篇:
Delphi读取Word发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap