J'ai déjà vu ce code sur le groupe, et impossible de remettre la main
dessus...
Je cherche à récupérer LES NOMS UNIQUEMENT de fichiers contenus dans un
répertoire. Le total des fichiers de la majorité de mes répertoires fait
plus de 255 caractères... et je suis en Access 2003.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Patrick Fredin
Bonjour,
Voici un exemple :
Function GetAllFilesInDir(ByVal strDirPath As String) As Variant
' Loop through the directory specified in strDirPath and save each
' file name in an array, then return that array to the calling procedure.
' Return False if strDirPath is not a valid directory.
Dim strTempName As String
Dim varFiles() As Variant
Dim lngFileCount As Long
On Error GoTo GetAllFiles_Err
' Make sure that strDirPath ends with a "" character.
If Right$(strDirPath, 1) <> "" Then
strDirPath = strDirPath & ""
End If
' Make sure strDirPath is a directory.
If GetAttr(strDirPath) = vbDirectory Then
strTempName = Dir(strDirPath, vbDirectory)
Do Until Len(strTempName) = 0
' Exclude ".", "..".
If (strTempName <> ".") And (strTempName <> "..") Then
' Make sure we do not have a sub-directory name.
If (GetAttr(strDirPath & strTempName) _
And vbDirectory) <> vbDirectory Then
' Increase the size of the array to accommodate the found filename
' and add the filename to the array.
ReDim Preserve varFiles(lngFileCount)
varFiles(lngFileCount) = strTempName
lngFileCount = lngFileCount + 1
End If
End If
' Use the Dir function to find the next filename.
strTempName = Dir()
Loop
' Return the array of found files.
GetAllFilesInDir = varFiles
End If
GetAllFiles_End:
Exit Function
GetAllFiles_Err:
GetAllFilesInDir = False
Resume GetAllFiles_End
End Function
-- Patrick "PatCatNats" wrote in message news:cn06r9$nhk$
Bonjour,
J'ai déjà vu ce code sur le groupe, et impossible de remettre la main dessus... Je cherche à récupérer LES NOMS UNIQUEMENT de fichiers contenus dans un répertoire. Le total des fichiers de la majorité de mes répertoires fait plus de 255 caractères... et je suis en Access 2003.
Quelqu'un aurait vu passer ce code...
Merci
Patrice
Bonjour,
Voici un exemple :
Function GetAllFilesInDir(ByVal strDirPath As String) As Variant
' Loop through the directory specified in strDirPath and save each
' file name in an array, then return that array to the calling
procedure.
' Return False if strDirPath is not a valid directory.
Dim strTempName As String
Dim varFiles() As Variant
Dim lngFileCount As Long
On Error GoTo GetAllFiles_Err
' Make sure that strDirPath ends with a "" character.
If Right$(strDirPath, 1) <> "" Then
strDirPath = strDirPath & ""
End If
' Make sure strDirPath is a directory.
If GetAttr(strDirPath) = vbDirectory Then
strTempName = Dir(strDirPath, vbDirectory)
Do Until Len(strTempName) = 0
' Exclude ".", "..".
If (strTempName <> ".") And (strTempName <> "..") Then
' Make sure we do not have a sub-directory name.
If (GetAttr(strDirPath & strTempName) _
And vbDirectory) <> vbDirectory Then
' Increase the size of the array to accommodate the
found filename
' and add the filename to the array.
ReDim Preserve varFiles(lngFileCount)
varFiles(lngFileCount) = strTempName
lngFileCount = lngFileCount + 1
End If
End If
' Use the Dir function to find the next filename.
strTempName = Dir()
Loop
' Return the array of found files.
GetAllFilesInDir = varFiles
End If
GetAllFiles_End:
Exit Function
GetAllFiles_Err:
GetAllFilesInDir = False
Resume GetAllFiles_End
End Function
--
Patrick
"PatCatNats" <patcat.nats@tiscali.fr> wrote in message
news:cn06r9$nhk$1@news.tiscali.fr...
Bonjour,
J'ai déjà vu ce code sur le groupe, et impossible de remettre la main
dessus...
Je cherche à récupérer LES NOMS UNIQUEMENT de fichiers contenus dans un
répertoire. Le total des fichiers de la majorité de mes répertoires fait
plus de 255 caractères... et je suis en Access 2003.
Function GetAllFilesInDir(ByVal strDirPath As String) As Variant
' Loop through the directory specified in strDirPath and save each
' file name in an array, then return that array to the calling procedure.
' Return False if strDirPath is not a valid directory.
Dim strTempName As String
Dim varFiles() As Variant
Dim lngFileCount As Long
On Error GoTo GetAllFiles_Err
' Make sure that strDirPath ends with a "" character.
If Right$(strDirPath, 1) <> "" Then
strDirPath = strDirPath & ""
End If
' Make sure strDirPath is a directory.
If GetAttr(strDirPath) = vbDirectory Then
strTempName = Dir(strDirPath, vbDirectory)
Do Until Len(strTempName) = 0
' Exclude ".", "..".
If (strTempName <> ".") And (strTempName <> "..") Then
' Make sure we do not have a sub-directory name.
If (GetAttr(strDirPath & strTempName) _
And vbDirectory) <> vbDirectory Then
' Increase the size of the array to accommodate the found filename
' and add the filename to the array.
ReDim Preserve varFiles(lngFileCount)
varFiles(lngFileCount) = strTempName
lngFileCount = lngFileCount + 1
End If
End If
' Use the Dir function to find the next filename.
strTempName = Dir()
Loop
' Return the array of found files.
GetAllFilesInDir = varFiles
End If
GetAllFiles_End:
Exit Function
GetAllFiles_Err:
GetAllFilesInDir = False
Resume GetAllFiles_End
End Function
-- Patrick "PatCatNats" wrote in message news:cn06r9$nhk$
Bonjour,
J'ai déjà vu ce code sur le groupe, et impossible de remettre la main dessus... Je cherche à récupérer LES NOMS UNIQUEMENT de fichiers contenus dans un répertoire. Le total des fichiers de la majorité de mes répertoires fait plus de 255 caractères... et je suis en Access 2003.