Advertisement
miguelhosttimer

procurar um arquivo pasta Downloads

May 15th, 2024
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.00 KB | None | 0 0
  1.    unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Edit1: TEdit;
  13.     procedure Button1Click(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.dfm}
  26.  
  27. procedure TForm1.Button1Click(Sender: TObject);
  28. var
  29.   FileName, DownloadFolder: string;
  30.   SearchRec: TSearchRec;
  31.   Found: Boolean;
  32. begin
  33.   FileName := Edit1.Text;
  34.   DownloadFolder := GetEnvironmentVariable('USERPROFILE') + '\Downloads\';
  35.   Found := FindFirst(DownloadFolder + FileName + '.*', faAnyFile, SearchRec) = 0;
  36.   if Found then
  37.     ShowMessage('O arquivo ' + FileName + ' foi encontrado na pasta de downloads.')
  38.   else
  39.     ShowMessage('O arquivo ' + FileName + ' não foi encontrado na pasta de downloads.');
  40.   FindClose(SearchRec);
  41. end;
  42.  
  43. end.
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement