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


    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

  • 相关阅读:
    [Python] Array Attributes of Numpy lib
    《火球——UML大战需求分析》(第2章 耗尽脑汁的需求分析工作)——2.1 需求分析面面观
    UVA 10201 Adventures in Moving
    《史蒂夫·乔布斯传》官方正式中文版电子书(高清晰完整版)
    为什么要用BitSet
    sed 技巧一例:特定位置插入
    Mac+IPAD上使用wireshark抓包
    【经验谈】XmlSerializer的坑
    HTML语言简单回顾
    不可思议的每日培训(1)——日复一日的每日分享
  • 原文地址:https://www.cnblogs.com/lantianhf/p/4707069.html
Copyright © 2020-2023  润新知