DIR([pathname] [,attributes])

Returns the name of a file or directory matching a pattern or attribute (String).


pathname(Optional) The full path of a file or directory (String).
attributes(Optional) A vbFileAttribute constant specifying the file attributes to (Integer):
0 = vbNormal (default)
1 = vbReadOnly
2 = vbHidden
4 = vbSystem
8 = vbVolume (Macintosh only)
16 = vbDirectory
64 = vbAlias (Macintosh only)

REMARKS
* The "pathname" may include a directory and drive.
* If "pathname" cannot be found, then a zero length string ("") is returned.
* The "attribute" can be a constant or a numerical expression.
* If "attributes" is left blank, then 0 is used. These are files that match "pathname" but have no attributes.
* The characters (*) and (?) can be used as wildcards.
* To iterate over all the files in a folder, specify an empty string for the "pathname"
* You must provide a "pathname" the first time that this function is called, otherwise an error will occur.
* To get additional file names, call this function again with no arguments.
* Any subsequent calls must specify a "pathname" otherwise an error will occur.
* When no more files exist an empty string is returned.
* File names are not necessarily returned in any particular order so it may be worth adding them to an array and sorting them before you display them.
* The vbAlias and vbVolumn attributes are only available on the Macintosh.
* You cannot call this function recursively.
* If "attribute" > 256, then it is assumed to be a MacID value.
* You can use the DIR$ function if you want to return a String data type instead of a Variant/String data type.
* You can use the MKDIR function to create new directories.
* If you are using SharePoint then you must use forward slashes instead of backward slashes between the subfolders.
* The equivalent .NET function is Microsoft.VisualBasic.FileSystem.Dir
* For the Microsoft documentation refer to docs.microsoft.com

Dir("C:\Windows\test.ini") 
Dir("C:\Windows\*ini")
Dir()
Dir("//sharepoint-site\folder\subfolder")

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited Top