DIR function example
This example uses the DIR function to check if some files or directories exist. On the Macintosh computer, the default drive name is "HD", and the path portion is separated by the colon. And the wildcard of Microsoft Windows can appear in the file name as a valid character in the Mac. You can also use the MacID function to specify the file group.
DIM myfile, mypath, myname 'returns "WIN.INI" (in Microsoft Windows) (if the file exists). MyFile = DIR ("c: /windows/win.ini") 'Returns the file name with the specified extension. If more than one * .ini file exists, 'functions will return the name of the file that is found in the condition. MyFile = DIR ("C: / Windows / *. INI") 'If the DIR function is called for the second time, but without any parameters, the function will return the next * .ini file in the same directory. MyFile = Dir 'Returns the first implicit * .txt file. MyFile = DIR ("*. Txt", vbhidden "shows the name in the C: / directory. Mypath = "c: /" 'specified path. MyName = DIR (mypath, vbdirectory "is looking for the first item. Do While MyName <> "" 'Start loop. 'Skip the current directory and the upper directory. If MyName <> "." And MyName <> ".." The 'use bit comparison to determine MyName represents a directory. IF (mypath & myname) = vbdirectory life debug.print myname 'If it is a directory, it is displayed. End if End if myname = dir 'looks for the next directory. Loop