Sign in Join
Wiki copytemporary

Create a new file date/de

Ändert das Erstellungsdatum einer Datei:

pascal
function funDateiDatumAendern(strDateiname: string;
  strNeuerZeitstempel: string): boolean;
var
  datNeuesDateidatum: TDateTime;

begin

  Result := False;

  // Prüft, ob die Datei vorhanden ist
  if not FileExists(strDateiname) then
    exit;

  // legt den aktuellen Datums- und Zeitstempel der Datei fest
  // Die Schreibweise des Datums richtet sich nach dem Betriebssystem
  // Die Schreibweise der Uhrzeit richtet sich nach Sommer- und Winterzeit

  datNeuesDateidatum := StrToDateTime(strNeuerZeitstempel);

  // StrToTime('03:00')
  // TryStrToDateTime

  // Setzt das neue Dateidatum
  FileSetDate(strDateiname, DateTimeToFileDate(datNeuesDateidatum));

  Result := True;

end;

Aufruf unter Windows:

pascal
  if not funDateiDatumAendern('E:\Test.txt', '10.01.2000 14:34:56') then
    ShowMessage('Fehler');

Aufruf unter Linux (Ubuntu):

pascal
  if not funDateiDatumAendern('/home/user/Dokumente/Test.txt', '10-1-00 14:34:56') then
    ShowMessage('Fehler');

--Olaf 06:44, 19 July 2013 (UTC)


From the Free Pascal wiki, page "Create a new file date/de", as it stood on 2020-01-16 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Edited on wiki.freepascal.org by 3 people, 2013–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
OlafCreated page
Olaf (minor)
FTurtle
BartUpdate code example (Utf8ToSys is a no-op by default in Lazarus)
BartCode example: don't compare to False, Pascal has a not operator...
BartUse pascal highlighter

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.