Hallo,
ich möchte überprüfen, ob eine Datei schon älter als eine Woche ist. Wenn ja, soll er sich eine Datei aus dem Internet runterladen. Wie mache ich das?
Danke im Voraus!
Hallo,
ich möchte überprüfen, ob eine Datei schon älter als eine Woche ist. Wenn ja, soll er sich eine Datei aus dem Internet runterladen. Wie mache ich das?
Danke im Voraus!
Sieh dir mal die Funktion
"FileGetTime" an,..
ZitatAlles anzeigen
FileGetTime
--------------------------------------------------------------------------------Returns the time and date information for a file.
FileGetTime ( "filename" [, option [, format]] )
Parameters
filename Filename to check.
option [optional] Flag to indicate which timestamp
0 = Modified (default)
1 = Created
2 = Accessed
format [optional] to specify type of return
0 = return an array (default)
1 = return a string YYYYMMDDHHMMSS
Damit komm ich nicht klar. Ich bekomm einen String den ich nicht (besser gesagt: ich weiß nicht wie) mit der Systemzeit verlgeichen kann.
Laut Hilfe:
Remarks:
The array is a single dimension array containing six elements:
$array[0] = year (four digits)
$array[1] = month (range 01 - 12)
$array[2] = day (range 01 - 31)
$array[3] = hour (range 00 - 23)
$array[4] = min (range 00 - 59)
$array[5] = sec (range 00 - 59)
Notice that return values are zero-padded.
Damit lässt sich doch was anfangen ?
rechnest das gesamt in Tage um, also
$Tage_neu = (@Year-1) * 365 + @Yday
$Tage_alt = ($array[0]-1) * 365 + ($array[1]-1) * 30 + $array[2]
Oder etwa nicht ?
und dann halt:
If $Tage_neu - 7 > $Tage_alt Then MsgBox( 0, '', 'älter als 1 Woche' )
So gings auch
#include <date.au3>
$FileCalcDate = FileGetTime("C:\datei.ext", 0, 1)
$FileCalcDate = _FileDateString2Calc($FileCalcDate)
$diff = _DateDiff("D",$FileCalcDate,_NowCalc())
; Author(s): Prog@ndy
Func _FileDateString2Calc($filedate)
Return StringRegExpReplace($filedate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6")
EndFunc ;==>_FileDateString2Calc
Ich hab jetzt Limettes Vorschlag genommen. Funktionert einwandfrei, Danke!
Oder so
Ist aber mehr Code
Edit: Danke x) Ich versuche StringRegExp möglichst zu vermeiden, diese Funktionen sind mir nicht geheuer xD