Create a new file date/de
Ändert das Erstellungsdatum einer Datei:
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:
if not funDateiDatumAendern('E:\Test.txt', '10.01.2000 14:34:56') then
ShowMessage('Fehler');Aufruf unter Linux (Ubuntu):
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.
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.
| When | Who | What changed |
|---|---|---|
| Olaf | Created page | |
| Olaf | (minor) | |
| FTurtle | ||
| Bart | Update code example (Utf8ToSys is a no-op by default in Lazarus) | |
| Bart | Code example: don't compare to False, Pascal has a not operator... | |
| Bart | Use pascal highlighter |
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
