Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$old_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ext-thumbnail_url is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
Cercare un file od un insieme di file sul disco fisso | IlSoftware.it

Cercare un file od un insieme di file sul disco fisso

Questo esempio si compone di due subroutine e consente di ricercare un file od un insieme di file all'interno di una cartella o dell'intero disco fisso.

Questo esempio si compone di due subroutine e consente di ricercare un file od un insieme di file all’interno di una cartella o dell’intero disco fisso. Il nome ed il percorso dei file trovati vengono memorizzati nel file di testo specificato.

Utilizzo:

Search32 "C:\", "*.DOC", "c:\DIR.TXT"

– al posto di C:\ indicate il disco fisso o la cartella all’interno della quale desiderate effettuare la ricerca;
– al posto di *.DOC specificate il file o l’insieme di file che desiderate cercare. E’ consentito l’uso delle wildcards (o caratteri jolly);
– al posto di c:\DIR.TXT indicate percorso e nome del file di testo che desiderate creare e che conterrà il risultato della ricerca.

Il codice Visual Basic

Sub Search32(dPath$, dpattern$, SFileName)
    Close #10
    Open SFileName For Output As 10
    Call dirloop(dPath$, dpattern$)
    Close #10
End Sub

Sub dirloop(thispath As String, thispattern As String)
    Dim thisfile, thesefiles, thesedirs, X, checkfile
    If Right$(thispath, 1) “\” Then thispath = thispath + “\”
    thisfile = Dir$(thispath + thispattern, 0)

    Do While thisfile “”
        Print #10, LCase$(thispath + thisfile)
        thisfile = Dir$
    Loop
    
    thisfile = Dir$(thispath + “*.”, 0)
    thesefiles = 0
    ReDim filelist(10)

    Do While thisfile “”
        thesefiles = thesefiles + 1

        If (thesefiles Mod 10) = 0 Then
         ReDim Preserve filelist(thesefiles + 10)
End If
filelist(thesefiles) = thisfile
thisfile = Dir$
Loop
thisfile = Dir$(thispath + “*.”, 16)
checkfile = 1
thesedirs = 0
ReDim dirlist(10)

Do While thisfile “”

If thisfile = “.” Or thisfile = “..” Then
ElseIf thisfile = filelist(checkfile) Then
checkfile = checkfile + 1
Else
thesedirs = thesedirs + 1
If (thesedirs Mod 10) = 0 Then ReDim Preserve dirlist(thesedirs + 10)
dirlist(thesedirs) = thisfile
End If
thisfile = Dir$
Loop

For X = 1 To thesedirs
Call dirloop(thispath + dirlist(X), thispattern): DoEvents
Next X
End Sub<

Ti consigliamo anche

Link copiato negli appunti