John Reynolds
June 28th, 2001, 10:55 AM
Why doesn't the following statement print ALL the files in the root dir?
Debug.print Dir("c:*.*")
Thanks!
Debug.print Dir("c:*.*")
Thanks!
|
Click to See Complete Forum and Search --> : Dir statement John Reynolds June 28th, 2001, 10:55 AM Why doesn't the following statement print ALL the files in the root dir? Debug.print Dir("c:*.*") Thanks! Cimperiali June 28th, 2001, 11:13 AM Dir Function Example This example uses the Dir function to check if certain files and directories exist. Dim MyFile, MyPath, MyName ' Returns "WIN.INI" if it exists. MyFile = Dir("C:\WINDOWS\WIN.INI") ' Returns filename with specified extension. If more than one *.ini ' file exists, the first file found is returned. MyFile = Dir("C:\WINDOWS\*.INI") ' Call Dir again without arguments to return the next *.INI file in the ' same directory. MyFile = Dir ' Return first *.TXT file with a set hidden attribute. MyFile = Dir("*.TXT", vbHidden) ' Display the names in C:\ that represent directories. MyPath = "c:\" ' Set the path. MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry. Do While MyName <> "" ' Start the loop. ' Ignore the current directory and the encompassing directory. If MyName <> "." And MyName <> ".." Then ' Use bitwise comparison to make sure MyName is a directory. If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then Debug.Print MyName ' Display entry only if it End If ' it represents a directory. End If MyName = Dir ' Get next entry. Loop Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |