Newsgroup: it.comp.lang.visual-basic
Titolo: probelma come find files

vorrei sapere l'esatta sintassi del comando findfiles
e sapere se ne esistono altri per trovare la locazione di un files
inserendone il nome e l'estensione
grazie

Scusami ma non sono pratico di NG ed ancora non avevo lettol il [MANIFESTO]:
(ignora pertanto il messaggio precedente che conteneva un allegato)
inserisci in un nuovo progetto i seguenti file:
1) modsearch.bas (qui sotto riportato)
Option Explicit
Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal
lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal
hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Public Const MAX_PATH = 260
Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type
Type WIN32_FIND_DATA
        dwFileAttributes As Long
        ftCreationTime As FILETIME
        ftLastAccessTime As FILETIME
        ftLastWriteTime As FILETIME
        nFileSizeHigh As Long
        nFileSizeLow As Long
        dwReserved0 As Long
        dwReserved1 As Long
        cFileName As String * MAX_PATH
        cAlternate As String * 14
End Type
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
Public Const FILE_ATTRIBUTE_NORMAL = &H80
2) frmsearch.frm
    (contenente: 2 controlli OptionButton le cui prop. name=optDIR  e optAPI
rispettivamente
                       2 controlli ListBox le cui proprietà name=listFILES e
listDIRS rispettivamente
                       1 controllo CommandButton la cui prop. name=cmdGO
                       1 controllo Label la cui proprietà name=lblTIME)
Option Explicit
Private Sub cmdgo_Click()
Dim starttime As Single
lstfiles.Clear
starttime = Timer
lstdirs.AddItem "C:\"
Do
  lbltime = "Searching . . . " & lstdirs.List(0)
  If optdir = True Then
    findfilesdir lstdirs.List(0), "*.*"
  Else
    findfilesapi lstdirs.List(0), "*.*"
  End If
  lstdirs.RemoveItem 0
Loop Until lstdirs.ListCount = 0
lstdirs.Visible = True
lstfiles.Visible = True
lbltime = "Time taken: " & Timer - starttime & " seconds"
End Sub
Sub findfilesapi(DirPath As String, FileSpec As String)
Dim FindData As WIN32_FIND_DATA
Dim FindHandle As Long
Dim FindNextHandle As Long
Dim filestring As String
DirPath = Trim$(DirPath)
If Right(DirPath, 1) <> "\" Then
  DirPath = DirPath & "\"
End If
' trova il primo file nella directory selezionata
FindHandle = FindFirstFile(DirPath & FileSpec, FindData)
If FindHandle <> 0 Then
  If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
    ' è una directory...
    If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName, 2)
<> ".." Then
      filestring = DirPath & Trim$(FindData.cFileName) & "\"
      lstdirs.AddItem filestring
    End If
  Else
    filestring = DirPath & Trim$(FindData.cFileName)
    lstfiles.AddItem filestring
  End If
End If
' ricerca tutti i file...
If FindHandle <> 0 Then
  Do
    DoEvents
    FindNextHandle = FindNextFile(FindHandle, FindData)
    If FindNextHandle <> 0 Then
      If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
        ' è una directory...
        If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName,
2) <> ".." Then
          filestring = DirPath & Trim$(FindData.cFileName) & "\"
          lstdirs.AddItem filestring
        End If
      Else
        filestring = DirPath & Trim$(FindData.cFileName)
        lstfiles.AddItem filestring
      End If
    Else
      Exit Do
    End If
  Loop
End If
Call FindClose(FindHandle)
End Sub
Public Sub findfilesdir(DirPath As String, FileSpec As String)
Dim filestring As String
DirPath = Trim$(DirPath)
If Right$(DirPath, 1) <> "\" Then
  DirPath = DirPath & "\"
End If
filestring = Dir$(DirPath & FileSpec, vbArchive Or vbHidden Or vbSystem Or
vbDirectory)
Do
  DoEvents
  If filestring = "" Then
    Exit Do
  Else
    If (GetAttr(DirPath & filestring) And vbDirectory) = vbDirectory Then
      If Left$(filestring, 1) <> "." And Left$(filestring, 2) <> ".." Then
        lstdirs.AddItem DirPath & filestring & "\"
      End If
    Else
      lstfiles.AddItem DirPath & filestring
    End If
  End If
  filestring = Dir$
Loop
End Sub
...enjoy yourself