Name
Dir Function
Class
Microsoft.VisualBasic.FileSystem
Syntax
Dir[(pathname[, attributes])]-
pathname Use: Optional
Data Type: String
A string expression that defines a path, which may contain a drive name, a folder name, and a filename
-
attributes Use: Optional
Data Type: Numeric or Constant of the
FileAttributeenumerationA
FileAttributeenumeration constant or numeric expression specifying the file attributes to be matched
Return Value
String
Description
Returns the name of a single file or folder matching the pattern and attribute passed to the function
Rules at a Glance
A zero-length string (“”) is returned if a matching file is not found.
Possible values for
attributesare:
|
FileAttribute enumeration |
Value |
Description |
|---|---|---|
|
|
0 |
Normal (not hidden and not a system file) |
|
|
1 |
Read-only file |
|
|
2 |
Hidden |
|
|
4 |
System file |
|
|
8 |
Volume label; if specified, all other attributes are ignored |
|
|
16 |
Directory or folder |
|
|
32 |
Archive |
|
|
64 |
Alias or link |
The
attributesconstants can beOred together to create combinations of attributes to match; e.g.,FileAttribute.HiddenOrFileAttribute.Directorywill match hidden directories.If
attributesis not specified, files matchingpathnameare returned regardless ofattributes.You can use the wildcard characters
*and?withinpathnameto return multiple files.Although
pathnameis optional, the first call you make toDirmust include it.pathnamemust also be specified if you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access