Sign in Join
Wiki copytemporary

Create a new file date/de: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-\
2-\
31Ändert das Erstellungsdatum einer Datei:
42
53``` pascal
64function funDateiDatumAendern(strDateiname: string;
75 strNeuerZeitstempel: string): boolean;
86var
97 datNeuesDateidatum: TDateTime;
108
119begin
1210
1311 Result := False;
1412
1513 // Prüft, ob die Datei vorhanden ist
1614 if not FileExists(strDateiname) then
1715 exit;
1816
1917 // legt den aktuellen Datums- und Zeitstempel der Datei fest
2018 // Die Schreibweise des Datums richtet sich nach dem Betriebssystem
2119 // Die Schreibweise der Uhrzeit richtet sich nach Sommer- und Winterzeit
2220
2321 datNeuesDateidatum := StrToDateTime(strNeuerZeitstempel);
2422
2523 // StrToTime('03:00')
2624 // TryStrToDateTime
2725
2826 // Setzt das neue Dateidatum
2927 FileSetDate(strDateiname, DateTimeToFileDate(datNeuesDateidatum));
3028
3129 Result := True;
3230
3331end;
3432```
3533
36-\
3734Aufruf unter Windows:
3835
3936``` pascal
4037 if not funDateiDatumAendern('E:\Test.txt', '10.01.2000 14:34:56') then
4138 ShowMessage('Fehler');
4239```
4340
44-\
4541Aufruf unter Linux (Ubuntu):
4642
4743``` pascal
4844 if not funDateiDatumAendern('/home/user/Dokumente/Test.txt', '10-1-00 14:34:56') then
4945 ShowMessage('Fehler');
5046```
5147
52-\
53-\
5448--Olaf 06:44, 19 July 2013 (UTC)
5549
5650---
5751*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](/wiki-contact).*
5852Category: Code Snippets/de
5953Category: Deutsch

Back to history