25/02/08 17:07
LuigiBiasi
ti ho scritto proprio adesso il codice:
testalo non so se funziona perchè non ho avuto il tempo di provarlo.
questo oggetto è molto più flessibile delle dir o file listbox.
ed è molto intuitivo.
Dim c As New FileSystemObject Dim dirve(10) As String Private Sub Form_Load() getfile "C:\", "prova.txt" End Sub Public Function getfile(path As String, filename As String) As Boolean Dim f As Folder Set f = c.GetFolder(path) Dim file(100) As String Dim directory(100) As String Dim i As Integer Dim tr As Boolean tr = False i = 0 For Each Folder In f.SubFolders directory(i) = path & Folder & "\" i = i + 1 Next i = 0 For Each Files In f.Files file(i) = Files i = i + 1 Next For i = 0 To UBound(file) If (file(i) = filename) Then 'fai quello che vuoi tr = True End If Next i If tr = False Then 'ha continuato il for non ha trovato il file For i = 0 To UBound(directory) getfile directory(i), filename Next i Else getfile = True 'esci dalla funzione positivamente End If End Function Function getdrive(drive As String) As Boolean If (c.DriveExists(drive)) Then 'il drive esiste getdrive = True End If getdrive = False End Function
testalo non so se funziona perchè non ho avuto il tempo di provarlo.
questo oggetto è molto più flessibile delle dir o file listbox.
ed è molto intuitivo.
Ultima modifica effettuata da LuigiBiasi 25/02/08 17:16
aaa