robinhocne Posted January 28, 2012 Report Share Posted January 28, 2012 (edited) Como pegar a data de modificação de uma pasta ? Edited January 29, 2012 by robinhocne Quote Link to comment Share on other sites More sharing options...
0 Jhonas Posted January 28, 2012 Report Share Posted January 28, 2012 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses DateUtils, FileCtrl; procedure DirectoryDateTimeInfo(const path : string); var sr : TSearchRec; modifiedTime : TDateTime; creationTimeSystem: TSystemTime; lastAccessTimeSystem: TSystemTime; lastWriteTimeSystem: TSystemTime; creationTime: TDateTime; lastAccessTime: TDateTime; lastWriteTime: TDateTime; begin if sysUtils.FindFirst(path, faDirectory, sr) = 0 then try modifiedTime := FileDateToDateTime(sr.Time); FileTimeToSystemTime(sr.FindData.ftCreationTime, creationTimeSystem); with creationTimeSystem do creationTime := EncodeDateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, wMilliseconds); FileTimeToSystemTime(sr.FindData.ftLastAccessTime, lastAccessTimeSystem); with lastAccessTimeSystem do lastAccessTime := EncodeDateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, wMilliseconds); FileTimeToSystemTime(sr.FindData.ftLastWriteTime, lastWriteTimeSystem); with lastWriteTimeSystem do lastWriteTime := EncodeDateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, wMilliseconds); ShowMessage(Format('Informações de Data e Hora para: "%s"', [path])); ShowMessage(Format('Data da Criação: "%s"', [DateTimeToStr(creationTime)])); ShowMessage(Format('Ultimo Acesso: "%s"', [DateTimeToStr(lastAccessTime)])); ShowMessage(Format('Data da Ultima Modificação: "%s"', [DateTimeToStr(lastWriteTime)])); ShowMessage(Format('Hora da Ultima Modificação: "%s"', [DateTimeToStr(modifiedTime)])); finally FindClose(sr); end else ShowMessage(Format('Não foi possível obter informação para "%s"', [path])); end; procedure TForm1.Button1Click(Sender: TObject); var path , local: string; begin path := 'C:\'; // Diretorio inicio... if SelectDirectory(path, [sdAllowCreate, sdPerformCreate, sdPrompt], 1000) then local := path; DirectoryDateTimeInfo(local); end; end.abraço Quote Link to comment Share on other sites More sharing options...
0 robinhocne Posted January 29, 2012 Author Report Share Posted January 29, 2012 Obrigado Jhonas, deu certinho, isso mesmo que eu precisava..... Quote Link to comment Share on other sites More sharing options...
Question
robinhocne
Como pegar a data de modificação de uma pasta ?
Edited by robinhocneLink to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.