码迷,mamicode.com
首页 > 移动开发 > 详细

Android实例-路径信息及文件和文件夹的操作

时间:2015-08-02 19:52:11      阅读:385      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

  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.

 

Android实例-路径信息及文件和文件夹的操作

标签:

原文地址:http://www.cnblogs.com/FKdelphi/p/4696577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!