Android執行個體-路徑資訊及檔案和檔案夾的操作

來源:互聯網
上載者:User

標籤:

 

  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   begin100     Files := TDirectory.GetFiles(TPath.GetTempPath + ‘/temp/‘);101     for I := 0 to high(Files) do102     begin103       TFile.Delete(Files[I]);104     end;105   end;106 end;107 108 end.

 

Android執行個體-路徑資訊及檔案和檔案夾的操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.