Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Dir Function

Class

Microsoft.VisualBasic.FileSystem

Syntax

Dir[(pathname[, attributes])]
pathname (optional; String)

A string expression that defines a path, which may contain a drive name, a folder name, and a filename

attributes (optional; Numeric or Constant of the FileAttribute enumeration)

A FileAttribute enumeration 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 attributes are:

FileAttribute enumeration

Value

Description

Normal

0

Normal (not hidden and not a system file)

ReadOnly

1

Read-only file

Hidden

2

Hidden

System

4

System file

Volume

8

Volume label; if specified, all other attributes are ignored

Directory

16

Directory or folder

Archive

32

Archive

Alias

64

Alias or link

  • The attributes constants can be Ored together to create combinations of attributes to match; e.g., FileAttribute.Hidden Or FileAttribute. Directory will match hidden directories.

  • If attributes is not specified, files matching pathname are returned regardless of attributes.

  • You can use the wildcard characters * and ? within pathname to return multiple files.

  • Although pathname is optional, the first call you make to Dir must include it. pathname must also be specified if you are specifying attributes. In addition, ...

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.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata