zoukankan      html  css  js  c++  java
  • Android实例-路径信息及文件和文件夹的操作(XE8+小米2)

    结果:

    GetTempFileName:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/tmp/tmp.iQIip24407

    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/data/com.embarcadero.Project1/lib

    GetCachePath:/data/data/com.embarcadero.Project1/cache

    GetPathRoot:/

    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

      1 unit Unit1;
      2 
      3 interface
      4 
      5 uses
      6   System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      7   FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ScrollBox,
      8   FMX.Memo, FMX.Controls.Presentation, FMX.StdCtrls;
      9 
     10 type
     11   TForm1 = class(TForm)
     12     Button1: TButton;
     13     Memo1: TMemo;
     14     Button2: TButton;
     15     Button3: TButton;
     16     Button4: TButton;
     17     Button5: TButton;
     18     procedure Button1Click(Sender: TObject);
     19     procedure Button2Click(Sender: TObject);
     20     procedure Button3Click(Sender: TObject);
     21     procedure Button4Click(Sender: TObject);
     22     procedure Button5Click(Sender: TObject);
     23   private
     24     { Private declarations }
     25   public
     26     { Public declarations }
     27   end;
     28 
     29 var
     30   Form1: TForm1;
     31 
     32 implementation
     33 uses
     34   System.IoUtils;
     35 {$R *.fmx}
     36 {$R *.NmXhdpiPh.fmx ANDROID}
     37 
     38 procedure TForm1.Button1Click(Sender: TObject);
     39 begin
     40   Memo1.Lines.Clear;
     41   Memo1.Lines.Add('GetTempFileName:' + TPath.GetTempFileName);
     42   Memo1.Lines.Add('GetTempPath:' + TPath.GetTempPath);
     43   Memo1.Lines.Add('GetHomePath:' + TPath.GetHomePath);
     44   Memo1.Lines.Add('GetDocumentsPath:' + TPath.GetDocumentsPath);
     45   Memo1.Lines.Add('GetSharedDocumentsPath:' + TPath.GetSharedDocumentsPath);
     46   Memo1.Lines.Add('GetLibraryPath:' + TPath.GetLibraryPath);
     47   Memo1.Lines.Add('GetCachePath:' + TPath.GetCachePath);
     48   Memo1.Lines.Add('GetPathRoot:' + TPath.GetPathRoot(TPath.GetCachePath));
     49   Memo1.Lines.Add('GetPublicPath:' + TPath.GetPublicPath);
     50   Memo1.Lines.Add('GetPicturesPath:' + TPath.GetPicturesPath);
     51   Memo1.Lines.Add('GetSharedPicturesPath:' + TPath.GetSharedPicturesPath);
     52   Memo1.Lines.Add('GetCameraPath:' + TPath.GetCameraPath);
     53   Memo1.Lines.Add('GetSharedCameraPath:' + TPath.GetSharedCameraPath);
     54   Memo1.Lines.Add('GetMusicPath:' + TPath.GetMusicPath);
     55   Memo1.Lines.Add('GetSharedMusicPath:' + TPath.GetSharedMusicPath);
     56   Memo1.Lines.Add('GetMoviesPath:' + TPath.GetMoviesPath);
     57   Memo1.Lines.Add('GetAlarmsPath:' + TPath.GetAlarmsPath);
     58   Memo1.Lines.Add('GetSharedAlarmsPath:' + TPath.GetSharedAlarmsPath);
     59   Memo1.Lines.Add('GetDownloadsPath:' + TPath.GetDownloadsPath);
     60   Memo1.Lines.Add('GetSharedDownloadsPath:' + TPath.GetSharedDownloadsPath);
     61   Memo1.Lines.Add('GetRingtonesPath:' + TPath.GetRingtonesPath);
     62   Memo1.Lines.Add('GetSharedRingtonesPath:' + TPath.GetSharedRingtonesPath);
     63 end;
     64 
     65 procedure TForm1.Button2Click(Sender: TObject);
     66 begin
     67   if TFile.Exists(TPath.GetTempFileName) then
     68   begin
     69     Memo1.Lines.Clear;
     70     Memo1.Lines.Add('存在');
     71   end;
     72 end;
     73 
     74 procedure TForm1.Button3Click(Sender: TObject);
     75 begin
     76   if not TDirectory.Exists(TPath.GetTempPath + 'NewDirectory') then
     77     TDirectory.CreateDirectory(TPath.GetTempPath + 'NewDirectory');
     78 end;
     79 
     80 procedure TForm1.Button4Click(Sender: TObject);
     81 var
     82   sFile1: string;
     83   sFile2: string;
     84 begin
     85   sFile1 := TPath.GetTempPath + '123.jpg';
     86   sFile2 := TPath.GetTempPath + '456.jpg';
     87   if not TFile.Exists(sFile1) then
     88   begin
     89     TFile.Copy(sFile1, sFile2);
     90   end;
     91 end;
     92 
     93 procedure TForm1.Button5Click(Sender: TObject);
     94 var
     95   Files: TStringDynArray;
     96   I: Integer;
     97 begin
     98   if TDirectory.Exists(TPath.GetTempPath + '/temp/') then
     99   begin
    100     Files := TDirectory.GetFiles(TPath.GetTempPath + '/temp/');
    101     for I := 0 to high(Files) do
    102     begin
    103       TFile.Delete(Files[I]);
    104     end;
    105   end;
    106 end;
    107 
    108 end.
  • 相关阅读:
    Flutter 中的基本路由
    BottomNavigationBar 自定义 底部导航条
    StatefulWidget 有状态组件
    flutte页面布局四
    flutter页面布局三
    flutter页面布局二
    设计模式-工厂方法模式
    设计模式-代理模式
    设计模式-装饰模式
    SpringBoot项目部署到服务器上,tomcat不启动该项目
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/4696577.html
Copyright © 2011-2022 走看看