AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Folder creation datetime

Ein Thema von WojTec · begonnen am 26. Mär 2013 · letzter Beitrag vom 27. Mär 2013
 
Volker Z.

Registriert seit: 3. Dez 2012
Ort: Augsburg, Bayern, Süddeutschland
419 Beiträge
 
Delphi XE4 Ultimate
 
#4

AW: Folder creation datetime

  Alt 27. Mär 2013, 02:37
Hi,

maybe the following code could be some help for you - feel free to use it, if you like
Delphi-Quellcode:
type
  TFileTime = (ftAccess, ftCreated, ftWrite);

function GetFileDateTime (const Filename : string; const Filetime : TFileTime) : TDateTime;
var
  f : TSearchRec;
  t : _FILETIME;
  s : _SYSTEMTIME;
  d : Integer;

  function GetTimeDiff : Integer;
  var
    t0, t1 : _SYSTEMTIME;
  begin
    GetLocalTime (t0);
    GetSystemTime (t1);

    Result := t0.wHour - t1.wHour;
  end;

begin
  Result := 0;

  try
    if FindFirst (Filename, faAnyFile, f) <> 0 then
      raise Exception.Create ('File ' + Filename + ' not found');

    case Filetime of
      ftAccess : t := f.FindData.ftLastAccessTime;
      ftCreated : t := f.FindData.ftCreationTime;
      ftWrite : t := f.FindData.ftLastWriteTime;
      else
        raise Exception.Create ('Invalid type of file time')
    end;

    if not FileTimeToSystemTime (t, s) then
      raise Exception.Create ('Could not convert file time to system time format');

    d := GetTimeDiff;
    with s do
      Result := EncodeDate (wYear, wMonth, wDay) + EncodeTime (wHour + d, wMinute, wSecond, wMilliseconds);

    Result := Result
  finally
    FindClose (f)
  end
end;
A call like
ShowMessage (FormatDateTime ('dddd, d. mmmm yyyy hh:nn:ss', GetFileDateTime ('any file or folder you address here', ftCreated))) should produce a message box showing the files / folders creation date.

Have a nice day
Volker Zeller
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:47 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz