Create a new file date/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Create a new file date/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | \ | |
| 2 | + | \ | |
| 3 | + | Ändert das Erstellungsdatum einer Datei: | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | function funDateiDatumAendern(strDateiname: string; | |
| 7 | + | strNeuerZeitstempel: string): boolean; | |
| 8 | + | var | |
| 9 | + | datNeuesDateidatum: TDateTime; | |
| 10 | + | ||
| 11 | + | begin | |
| 12 | + | ||
| 13 | + | Result := False; | |
| 14 | + | ||
| 15 | + | // Prüft, ob die Datei vorhanden ist | |
| 16 | + | if not FileExists(strDateiname) then | |
| 17 | + | exit; | |
| 18 | + | ||
| 19 | + | // legt den aktuellen Datums- und Zeitstempel der Datei fest | |
| 20 | + | // Die Schreibweise des Datums richtet sich nach dem Betriebssystem | |
| 21 | + | // Die Schreibweise der Uhrzeit richtet sich nach Sommer- und Winterzeit | |
| 22 | + | ||
| 23 | + | datNeuesDateidatum := StrToDateTime(strNeuerZeitstempel); | |
| 24 | + | ||
| 25 | + | // StrToTime('03:00') | |
| 26 | + | // TryStrToDateTime | |
| 27 | + | ||
| 28 | + | // Setzt das neue Dateidatum | |
| 29 | + | FileSetDate(strDateiname, DateTimeToFileDate(datNeuesDateidatum)); | |
| 30 | + | ||
| 31 | + | Result := True; | |
| 32 | + | ||
| 33 | + | end; | |
| 34 | + | ``` | |
| 35 | + | ||
| 36 | + | \ | |
| 37 | + | Aufruf unter Windows: | |
| 38 | + | ||
| 39 | + | ``` pascal | |
| 40 | + | if not funDateiDatumAendern('E:\Test.txt', '10.01.2000 14:34:56') then | |
| 41 | + | ShowMessage('Fehler'); | |
| 42 | + | ``` | |
| 43 | + | ||
| 44 | + | \ | |
| 45 | + | Aufruf unter Linux (Ubuntu): | |
| 46 | + | ||
| 47 | + | ``` pascal | |
| 48 | + | if not funDateiDatumAendern('/home/user/Dokumente/Test.txt', '10-1-00 14:34:56') then | |
| 49 | + | ShowMessage('Fehler'); | |
| 50 | + | ``` | |
| 51 | + | ||
| 52 | + | \ | |
| 53 | + | \ | |
| 54 | + | --Olaf 06:44, 19 July 2013 (UTC) | |
| 55 | + | ||
| 56 | + | --- | |
| 57 | + | *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).* | |
| 58 | + | Category: Code Snippets/de | |
| 59 | + | Category: Deutsch |
