cs_ebernar
Messages postés4Date d'inscriptionvendredi 4 avril 2003StatutMembreDernière intervention30 janvier 2006
-
30 janv. 2006 à 16:29
cs_ebernar
Messages postés4Date d'inscriptionvendredi 4 avril 2003StatutMembreDernière intervention30 janvier 2006
-
30 janv. 2006 à 19:45
Bonjour,
J'ai besoin, pour un script de purge de fichiers inutiles, de récupérer la date de dernière modification d'un répertoire. J'arrive à le faire pour un fichier mais pas pour un répertoire.
Gobillot
Messages postés3140Date d'inscriptionvendredi 14 mai 2004StatutMembreDernière intervention11 mars 201934 30 janv. 2006 à 18:45
aucun composant n'est nécessaire, c'est du natif (librairie VBA)
MsgBox VBA.FileDateTime("C:\WINDOWS")
sinon il y a les API
attention j'ai changé les FILETIME en Currency
Const INVALID_HANDLE_VALUE = -1
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As Currency
ftLastAccessTime As Currency
ftLastWriteTime As Currency
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Private Declare Function FindFirstFile Lib "kernel32" Alias
"FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As
WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFile As Long) As Long
Private Declare Function FileTimeToLocalFileTime Lib "kernel32" Alias "FileTimeToLocalFileTime" (lpFileTime As Currency, lpLocalFileTime As Currency) As Long
Private Sub Command1_Click()
Dim FindData As WIN32_FIND_DATA
Dim Cur As Currency
Dim nom As String
Dim hfind As Long
Dim dt As Date
nom = "C:\WINDOWS"
hfind = FindFirstFile(nom, FindData)
If hfind = INVALID_HANDLE_VALUE Then Exit Sub
FindClose hfind
FileTimeToLocalFileTime FindData.ftLastWriteTime, Cur