Novas funções para copiar, mover ou excluir registro no Delphi Tokyo
Este exemplo demostra a cópia, movimentação e exclusão de arquivos através
dos métodos da classe TFile.
É necessário declarar System.IOUtils.
Exemplo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| procedure TForm1.operations(Sender: TObject);
begin
try
{ Copy file from source file path to destination file path }
if Sender = btnCopy then
TFile.Copy(edSourcePath.Text, edDestinationPath.Text);
{ Move file from source file path to destination file path }
if Sender = btnMove then
TFile.Move(edSourcePath.Text, edDestinationPath.Text);
{ Delete file from source file path }
if Sender = btnDelete then
TFile.Delete(edSourcePath.Text);
except
MessageDlg('Incorrect path', mtError, [mbOK], 0);
Exit;
end;
end; |
procedure TForm1.operations(Sender: TObject);
begin
try
{ Copy file from source file path to destination file path }
if Sender = btnCopy then
TFile.Copy(edSourcePath.Text, edDestinationPath.Text);
{ Move file from source file path to destination file path }
if Sender = btnMove then
TFile.Move(edSourcePath.Text, edDestinationPath.Text);
{ Delete file from source file path }
if Sender = btnDelete then
TFile.Delete(edSourcePath.Text);
except
MessageDlg('Incorrect path', mtError, [mbOK], 0);
Exit;
end;
end;
Fonte: http://docwiki.embarcadero.com/CodeExamples/Tokyo/en/FileOperations_(Delphi)
-
Giovani Da Cruz
-
4.876 views
- 0 comentários
- 2 de maio de 2017
Está gostando do conteúdo? Considere pagar um cafezinho para nossa equipe!
Posts Relacionados - Continue Aprendendo